这就是我现在正在做的事情。我收到以下错误
android.content.ActivityNotFoundException:找不到要处理的Activity 意图{act = android.intent.action.CALL dat = 16477210790}
@Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(store_contact_no.getText().toString()));
startActivity(callIntent);
}
答案 0 :(得分:0)
您不需要在清单中声明拨号意图过滤器,也不需要ACTION_DIAL的任何权限。寻找我的实现
private boolean isTelephonyEnabled(){
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
return tm != null && tm.getSimState()==TelephonyManager.SIM_STATE_READY;}
也很好检查设备上支持的电话
(defn-
str<->int [str]
(let [n (read-string str)]
(if (integer? n) n)))
(with-open [file (reader "/path/to/foo.txt")]
(try
(doseq [v (clojure-csv.core/parse-csv file)]
(clojure.java.jdbc/insert! db :records
nil
[(v 0) (v 1) (v 2) (str<->int (v 3))]))
(println "Records inserted successfully")
(Exception e
(println (.getNextException e) e))))
使用此代码。 这可能会对你有所帮助。
答案 1 :(得分:0)
将此添加到您的清单
<uses-permission android:name="android.permission.CALL_PHONE" />
在“活动检查”权限中,
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.CALL_PHONE}, 1);
}
} else {
Call(sNumber);
}
其中sNumber是您在字符串中的数字
然后覆盖onRequestPermissionsResult
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case 100:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted,
Call(sNumber);
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CALL_PHONE)) {
requestPermissions(new String[]{Manifest.permission.CALL_PHONE}, 1);
}
}
break;
}
}
添加此方法,
private void Call(String sNumber)
{
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + sNumber));
startActivity(callIntent);
}