zu erkennen Ich möchte nur einen Toast zeigen, wenn ein Anruf empfangen wird, aber nichts passiert und es nicht einmal auf OnReceive
im Debugging-Modus stoppt. Ich kann nicht herausfinden, warum es nicht am onReceive gestoppt wird. Es ist so, als würde es nicht einmal eine Absicht bekommen.Ich versuche eingehende Anrufe in Android
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rajatgupta.broadcastrecieverexample">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="MyReciever">
<intent-filter>
<action android:name="rajat_action">
</action>
</intent-filter>
</receiver>
<receiver android:name=".IncomingCall">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE">
</action>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
IncomingCall.java
public class IncomingCall extends BroadcastReceiver {
Context mContext;
@Override
public void onReceive(Context context, Intent intent) {
try {
Log.d("Intent", "Intent Detected");
Toast.makeText(context," Receiver start ",Toast.LENGTH_SHORT).show();
}
catch (Exception e){
e.printStackTrace();
}
}
}
Was mache ich falsch?