[英]BroadcastReceiver not working
I have a BroadcastReceiver
. 我有一个
BroadcastReceiver
。
AndroidManifest.xml
: AndroidManifest.xml
:
<!-- When starting calculator-->
<receiver android:name=".APP_CALCULATOR_class" >
<intent-filter>
<action android:name="android.intent.category.APP_CALCULATOR" >
</action>
</intent-filter>
</receiver>
APP_CALCULATOR_class.class
: APP_CALCULATOR_class.class
:
package com.startcalcevent.startcalcevent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class APP_CALCULATOR_class extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Calculator is on" , Toast.LENGTH_LONG).show();
}
}
Why is this code not working when I open the calculator application? 为什么在打开计算器应用程序时此代码不起作用?
I will only start when you send an Intent that is broadcasted. 我只会在您发送广播的Intent时开始。 A App_CALCULATOR category Intent with action (ACTION_MAIN) is not broadcasted (using
sendBroadcast(Intent)
) but started as an Activity using startActivity(Intent);
不广播App_CALCULATOR类别的带动作的意图(ACTION_MAIN)(使用
sendBroadcast(Intent)
),但使用startActivity(Intent);
作为活动启动startActivity(Intent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.