2014-10-03 44 views
1

我想啓動我的服務應用程序進入祕密代碼調用diler和它dosnt工作。啓動服務與祕密代碼android

這裏是我的清單文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="org..." 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="19" /> 

    <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
    <uses-permission android:name="android.permission.READ_CALL_LOG" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" > 
     </activity> 

     <receiver android:name=".IncomingCall" > 
      <intent-filter> 
       <action android:name="android.intent.action.PHONE_STATE" /> 
      </intent-filter> 
     </receiver> 

     <service 
      android:name="sniffingService" 
      android:label="androidCallProvider" > 
     </service> 

     <receiver android:name=".secretCodeApplicationStarter$onReceive" > 
      <intent-filter> 
       <action android:name="android.provider.Telephony.SECRET_CODE" /> 
       <data 
        android:scheme="android_secret_code" 
        android:host="9091"/> 
      </intent-filter> 
     </receiver> 
    </application> 

</manifest> 

這是我的廣播接收器:

import android.content.BroadcastReceiver; 
import android.content.Context; 
import android.content.Intent; 
import android.util.Log; 

public class secretCodeApplicationStarter extends BroadcastReceiver { 

    @Override 
    public void onReceive(Context context, Intent intent) { 
     if(intent.getAction().equals("android.provider.Telephony.SECRET_CODE")) { 
      Log.d("Helloo","Helloo"); 
      Intent i= new Intent(context, sniffingService.class); 
      context.startService(i); 
     } 
    } 

} 

這是從來沒有執行,所以我的服務永遠不會開始了。有任何想法嗎 ?

+0

是android:scheme =「android_secret_code」包含預期密碼的變量嗎?像這樣,它期待「android_secret_code」,如果你真的搜索名爲「android_secret_code」的字符串,請將其更改爲android:scheme =「@ string/android_secret_code」。 – 2014-10-03 13:55:59

+0

你想添加字符串resurces android_secret_code = 9091? – 2014-10-03 14:10:46

+0

找到一個已經可以啓動別的東西的密碼。例如,在Galaxy S4上,*#06#啓動了一個顯示您MEID的東西。一旦找到可用的代碼,請嘗試將您的代碼設置爲相同的代碼並查看它是否啓動。 這是我現在試圖弄清楚這個問題的地方。如果我設置了一個任意代碼,S4上沒有任何反應。如果我劫持現有的代碼(如06),它就可以工作。其含義是某處有一個撥號程序將啓動廣播的代碼列表。這個清單在哪裏?它可以添加到?就是那個問題。 – JamieB 2014-10-10 19:57:45

回答

1

在您的接收器聲明中使用android:name=".secretCodeApplicationStarter"而不是android:name=".secretCodeApplicationStarter$onReceive"

+0

我嘗試了這個dosnt工作! – 2014-10-03 13:33:48

+0

您是否在測試代碼之前啓動您的應用程序? – cygery 2014-10-03 13:52:54

+0

不,我想用此代碼啓動應用程序 – 2014-10-03 14:13:46