Slu*_*ggo 21 android phone-call phone-number android-intent android-permissions
我正试图让我的应用程序从EditText调用一个数字,但我得到:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL dat=Ring Tel nr. 123456789 }
Run Code Online (Sandbox Code Playgroud)
我已经搜索了一段时间以获得答案,但大多数答案都是权限并向Manifest添加活动.我做过两件事,如果我做错了.我在手机上运行它,而不是模拟器.我曾尝试使用和不使用intent-filters.以下是代码:清单:<uses-permission android:maxSdkVersion="19" android:name="android.permission.CALL_PHONE"/>
<activity
android:name="nu.sluggo.testapp.annons.Activity2">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
拨打电话的按钮(从SharedPrefs获取电话号码到下面的a1 :)
knapp_ring.setOnClickListener(new View.OnClickListener() {
Intent call = new Intent(Intent.ACTION_DIAL);
@Override
public void onClick(View v){
call.setData(Uri.parse("Telnr:" + a1));
startActivity(call);
}
});
Run Code Online (Sandbox Code Playgroud)
Com*_*are 67
Ring Tel nr. 123456789
不是有效的电话号码,这就是您的电话号码Intent
."Telnr:" + a1
也似乎没有效果.使用tel:
后跟电话号码作为传递给的值Uri.parse()
:
Uri.parse("tel:" + a1)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22531 次 |
最近记录: |