Can anyone tell wats wrong here... I am new to Android but NOT to Java.. I 
am getting the error "Unfortunately App Stopped" while running it in 
emulator. 
Can anyone help to figure the error out here: (Plz note that I have already 
set the permission for Intent. Actually below ACTION_CALL Intent is working 
fine without adding any Button. But when I add the button and registers the 
OnClickListener, it starts giving the error.) So wats wrong below while 
registering the listener?
 
Appreciate the response.. Let me know if any other info u need to debug..
 
*My activity java file is:*
package os.androidphonedialer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.content.Intent;
import android.net.Uri;
import android.widget.Button;
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final Button callButton = (Button) findViewById(R.id.callButton);
        callButton.setOnClickListener(new Button.OnClickListener() {public 
void onClick(View v){
         Intent callIntent = new 
Intent(Intent.ACTION_CALL,Uri.parse("tel:5551212"));
         callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(callIntent);
         }
    });
        setContentView(R.layout.activity_main);
    }
   @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is 
present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
 }
 
*And the layout file is:*
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
    xmlns:tools="http://schemas.android.com/tools";
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
<Button
    android:id="@+id/callButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Show Dialer" />
</RelativeLayout>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to