我写了一个BroadcastReceiver
课程,用于在充电器断开时接收广播意图,但在断开充电器时它不会显示Toast。
Logcat也没有显示任何内容。我在wifi上使用ADB。
请帮忙
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class My extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
Toast.makeText(arg0, "hello", Toast.LENGTH_LONG).show();
}
}
这是我的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sumitaich.sunsick"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/hacker"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name=".My">
<intent-filter>
<action android:name="com.sumitaich.sunsick.POWER_CONNECTED" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="oauth" android:host="t4jsample"/>
</intent-filter>
</activity>
<activity
android:name=".Detail"
android:label="@string/title_activity_detail"
android:parentActivityName="com.sumitaich.sunsick.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.sumitaich.sunsick.MainActivity" />
</activity>
</application>
答案 0 :(得分:0)
将您在Android清单中的操作更改为:
Cipher cipher = Cipher.getInstance("RSA");