着信時にアプリを起動したい。1) 着信があるたびに、ユーザーはポップアップウィンドウを取得し、どのアプリケーションを呼び出したいかをユーザーに尋ねます i) デフォルトの電話アプリケーションまたは ii) MyApplication 私は次のコードを使用しています
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 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>