0
我在Android應用程序開發的新,我想提出一個應答機應用程序,以及需要幫助..如何創建一個擴展廣播接收器的類?
- 如何開始的時候我在我的啓動類擴展了BroadcastReceiver類?
- 使用哪種方法自動接聽電話?
請幫助
我在Android應用程序開發的新,我想提出一個應答機應用程序,以及需要幫助..如何創建一個擴展廣播接收器的類?
請幫助
創建廣播reciever
public class Yourclass extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Intent Detected.", Toast.LENGTH_LONG).show();
}
}
2.註冊廣播reciever
您可以在清單或通過寫Context.registerReceiver() method.
下面是當應用程序被在定義的狀態調用onRecieve()方法來執行您需要採取的行動清單
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name="MyReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>
</application>
如何處理broadcastreceiver? – Harshid