2014-10-05 112 views
0

我有這個設備管理員priviledge應用程序與一些廣播公司(我正在適當的時間註冊和註冊!),問題是我的應用程序啓動設備啓動,我不沒有任何意圖過濾這個意圖,並使我的應用程序開始! ,請參閱AndroidManifest.xml中如下:應用程序不應該啓動在啓動但開始

<?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> 

正如你可以看到我已經在項值清單中評論所以它應該路徑引導事件到我的但是我的應用從activateSERVICE開始的.java肚裏如下:

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; 
} 

}

請告訴我爲什麼我的應用程序啓動(我證實,我的應用程序從activateSERVI開始? CE是因爲只有這個代碼設置變量USBpluggedIn = true的原因;只有當這個設置,我的應用程序啓動xyzService.class這是開始。 )

回答

0

您正在接收android.hardware.usb.action.USB_DEVICE_ATTACHED廣播,因爲有些USB設備在引導時連接到設備。

+0

即使沒有連接任何USB設備,它仍會彈出,但解決方案並非如此簡單。 – Naaz 2014-10-05 09:26:32

+0

你看過日誌嗎?並檢查傳遞給您的接收器的意圖,這應該包含什麼觸發廣播的信息。 – Okas 2014-10-05 09:28:28

+0

雅我做到了,但也許我會再次注意日誌,問題是,這種情況發生在手機啓動時,應用程序在開機時悄然打開,到那時候ADB未激活,因此無法使用LOGCAT! – Naaz 2014-10-05 09:38:56

相關問題