Android 应用程序不应在启动时启动,但应在启动时启动
我与一些广播公司(我在正确的时间注册和注销!)有这个设备管理员特权应用程序,问题是我的应用程序在设备启动时启动,我没有任何意图过滤这个意图并启动我的应用程序,请参见AndroidManifest.xml,如下所示:Android 应用程序不应在启动时启动,但应在启动时启动,android,android-intent,android-service,Android,Android Intent,Android Service,我与一些广播公司(我在正确的时间注册和注销!)有这个设备管理员特权应用程序,问题是我的应用程序在设备启动时启动,我没有任何意图过滤这个意图并启动我的应用程序,请参见AndroidManifest.xml,如下所示: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.winacro.xyz"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.winacro.xyz"
android:versionCode="1"
android:versionName="1.0" >
<!--uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /-->
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Fullscreen" >
<activity
android:name="com.winacro.xyz.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Fullscreen" >
</activity>
<activity
android:name="com.winacro.xyz.Boot"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.winacro.xyz.Xyz"
android:screenOrientation="portrait"
android:theme="@style/Fullscreen"
android:label="@string/app_name" />
<activity
android:name="com.winacro.xyz.Locked"
android:screenOrientation="portrait"
android:theme="@style/Fullscreen"
android:label="@string/app_name" />
<service
android:name="com.winacro.xyz.xyzService"
android:enabled="true" >
</service>
<receiver android:name="com.winacro.xyz.MyBroadcastReceiver" >
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
android:resource="@xml/device_filter" />
</receiver>
<receiver android:name="com.winacro.xyz.activateSERVICE" >
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</receiver>
<!-- Device Admin Receiver -->
<receiver
android:name="com.winacro.xyz.DeviceAdminR"
android:permission="android.permission.BIND_DEVICE_ADMIN" >
<intent-filter>
<!-- This action is required -->
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
<!-- This is required this receiver to become device admin component. -->
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/policies" />
</receiver>
</application>
public class activateSERVICE extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Boolean Set True", Toast.LENGTH_SHORT).show();
//Intent startActSerIntent = new Intent(context, Boot.class);
Intent i = new Intent();
i.setClassName("com.winacro.xyz", "com.winacro.xyz.Boot");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent startService = new Intent(context, xyzService.class);
context.startService(startService);
context.startActivity(i);
//context.startActivity(startActSerIntent);
xyzService.USBpluggedIn = true;
}
}
请告诉我为什么我的应用程序启动?(我确认我的应用程序从activateSERVICE启动是因为只有此代码设置变量USBpluggedIn=true;并且只有设置了此变量,我的应用程序才会启动正在启动的xyzService.class。)您正在接收android.hardware.usb.action.usb\u DEVICE\u连接的广播,因为某些usb设备在启动时连接到设备。不,它仍然会弹出,即使没有连接任何usb设备,解决方案也不是那么简单。您看过日志了吗?检查发送给你的接收者的意图,这应该包含触发广播的信息。是的,我做了,但也许我会再次注意日志,问题是,当手机启动,应用程序在引导时立即打开时,就会发生这种情况,此时ADB未激活,因此无法使用LOGCAT!意图是什么?我明白了。如果所有其他操作都失败,请在onreceive中创建一个普通文件,并在其中写入您的信息。然后您可以稍后提取此文件。