I've built a small app. The only thing it does is, catch an outgoing call and show some activity when it happens. There is just an Activity
and a BroadcastReceiver
.
I wanted to integrate my code with another application, I removed the BroadcastReceiver from the Manifest.xml
and created (and registered) it dynamically from the main activity. My receiver fired well but the activity is not shows up.
What is the difference between the two methods?
How can I make the activity to show up?
from MainActivity.java
:
callInterceptor = new InterceptOutgoingCall();
IntentFilter callInterceptorIntentFilter = new IntentFilter("android.intent.action.NEW_OUTGOING_CALL");
callInterceptorIntentFilter.setPriority(100);
registerReceiver(callInterceptor, callInterceptorIntentFilter);
and from the function receiver.onReceive(Context,Intent)
:
Intent alertIntent = new Intent(context, AlertActivity.class);
alertIntent.putExtra("callnumber", phonenbr);
alertIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(alertIntent);
my activity is declared in the manifest
like this:
<activity android:name=".AlertActivity"
android:screenOrientation="portrait"/>