Reputation: 41
I want to launch an application when there is a incoming call. 1) whenever there is a incoming call a user get a pop up window which ask user which application you want to invoke i) Default telephone application OR ii) MyApplication i am using following code
public class Record extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
Bundle bundle=arg1.getExtras();
String state=bundle.getString(TelephonyManager.EXTRA_STATE);
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
{
Intent i=new Intent(arg0,TempDemoActivity.class);
arg0.startActivity(i);
}
}
}
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="temp.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".TempDemoActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".Record" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
Upvotes: 1
Views: 2195
Reputation: 397
Intent intent = new Intent(context, DisplayScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
try this one
Upvotes: 1