棉花糖打来的电话之前无法检索号码 [英] Unable to retrieve number before incoming call in marshmallow
本文介绍了棉花糖打来的电话之前无法检索号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能够在其他版本的android中检索来电号码,但无法在marshmallow android
I am able to retrieve incoming call number in other version of android but unable to retrieve incoming call number in marshmallow android
public void onReceive(Context context, Intent intent) {
mContext=context;
if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) {
String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
Toast.makeText(context, "Call from:" + incomingNumber, Toast.LENGTH_LONG).show();
final Thread thread=new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
intentStart = new Intent(mContext.getApplicationContext(), MainActivity.class);
intentStart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intentStart);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
});
thread.start();
}}
推荐答案
当应用程序没有PHONE权限时,就会发生这种情况. 工作原理- http://developer.android.com/intl/es/training/permissions/index.html#permission-groups
It's happens when application don't have PHONE permission. How it's works - http://developer.android.com/intl/es/training/permissions/index.html#permission-groups
这篇关于棉花糖打来的电话之前无法检索号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文