I am just a new starter studying Android; I am trying to use intent-filter to receive an ACTION_DIAL intent from the ADB shell; here is what my ADB command is: "am start -a android.intent.action.DIAL -d "tel:1234567" I was planning to use my app to receive this intent after it is launched, and read the phone number from it; it received intent for the first time but could never receive them again, here's what I contained in my manifest file. my app uses the target api 31.
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel"/>
</intent-filter>
</activity>
and in my main activity here is only those code:
Intent intent = getIntent();
if(intent.getData()!=null) {
Context context = getApplicationContext();
CharSequence text = "TEST";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
I am not sure how the getIntent() works, it seems like a listener that can be triggered by multiple times, but the only intent I could receive is the "android.intent.action.MAIN", which is the default intent when the activity start