Toda vez que tento fazer uma ligação um erro é gerado e a aplicação é encerrada.
Implementação do item de menu na classe ListaAlunosActivity
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
MenuItem ligar = menu.add("Ligar");
ligar.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent irParaTelaDeDiscagem = new Intent(Intent.ACTION_CALL);
Uri discarPara = Uri.parse("tel:"+alunoSelecionado.getTelefone());
irParaTelaDeDiscagem.setData(discarPara);
startActivity(irParaTelaDeDiscagem);
return false;
}
});
Permissão no AndroidMainfest.xml
<uses-permission android:name="android.permission.CALL_PHONE"/>
LogCat
11-19 18:37:31.895: D/AndroidRuntime(1642): Shutting down VM
11-19 18:37:31.906: E/AndroidRuntime(1642): FATAL EXCEPTION: main
11-19 18:37:31.906: E/AndroidRuntime(1642): Process: br.com.example.cadastro, PID: 1642
11-19 18:37:31.906: E/AndroidRuntime(1642): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:xxxxxxxx }
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1765)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1485)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.Activity.startActivityForResult(Activity.java:3736)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.Activity.startActivityForResult(Activity.java:3697)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.Activity.startActivity(Activity.java:4007)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.Activity.startActivity(Activity.java:3975)
11-19 18:37:31.906: E/AndroidRuntime(1642): at br.com.caelum.cadastro.ListaAlunosActivity$3.onMenuItemClick(ListaAlunosActivity.java:120)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1017)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.widget.AdapterView.performItemClick(AdapterView.java:300)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.widget.AbsListView.performItemClick(AbsListView.java:1143)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3044)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.widget.AbsListView$3.run(AbsListView.java:3833)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.os.Handler.handleCallback(Handler.java:739)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.os.Handler.dispatchMessage(Handler.java:95)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.os.Looper.loop(Looper.java:135)
11-19 18:37:31.906: E/AndroidRuntime(1642): at android.app.ActivityThread.main(ActivityThread.java:5221)
11-19 18:37:31.906: E/AndroidRuntime(1642): at java.lang.reflect.Method.invoke(Native Method)
11-19 18:37:31.906: E/AndroidRuntime(1642): at java.lang.reflect.Method.invoke(Method.java:372)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
11-19 18:37:31.906: E/AndroidRuntime(1642): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
11-19 18:37:34.995: I/Process(1642): Sending signal. PID: 1642 SIG: 9
Informações adicionais: Emulador (Target Name: Android 5.0 / Platform: 5.0 / API Level: 21). SDK:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />