Thursday, 8 August 2013

com.android.phone stopped working

com.android.phone stopped working

just now start building small applications in Android.I tried to initiate
a call on button click by calling Call Intent. I have set the necessary
permissions in Manifest file.
But still I am getting error message as
com.android.phone stopped working

<Linear Layout
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:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnShow"
android:text="@string/btnShow"
android:fontFamily="sans-serif" />
</LinearLayout>
MainActvity.java
package com.example.androidproject2;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnShowDialer=(Button) findViewById(R.id.btnShow);
btnShowDialer.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0) {
try
{ Intent callIntent=new
Intent(android.content.Intent.ACTION_CALL,Uri.parse("tel:1121121212"));
startActivity(callIntent);
}
catch(Exception e)
{
Log.e("Trail","Call Falied", e);
}
}
});
}
}

No comments:

Post a Comment