2013-02-06 9 views
7

To, co mam tak daleko, ale nic się nie dzieje, gdy wejście to kombinacja komunikatorAndroid. Uruchomienie aplikacji z Dialer

public class DialReceiver extends BroadcastReceiver 
{ 
    @Override 
    public void onReceive(Context context, final Intent intent) { 

    if (intent.getAction().equals(android.content.Intent.ACTION_NEW_OUTGOING_CALL)) { 
     String phoneNumber = intent.getExtras().getString(android.content.Intent.EXTRA_PHONE_NUMBER); 

     if(phoneNumber.equals("*#588637#")) { 
      Intent intent1 = new Intent(context , Activity.class); 
      intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      context.startActivity(intent1); 
     } 

    } 

} 
} 

iw androidmanifest

<receiver 
     android:name=".receiver.DialReceiver" 
     android:exported="true" 
     android:process=":background" 
     tools:ignore="ExportedReceiver" > 
     <intent-filter> 
      <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </receiver> 

Odpowiedz

6

Spróbuj z tych małych zmian ..

String phoneNumber = intent.getExtras.getString("Intent.EXTRA_PHONE_NUMBER"); 

      if(phoneNumber.equals("*#588637#")) { 
      //do your stuff 
      } 

Nie zapomnij dodać tej linii do pliku Manifest.xml.

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

także można znaleźć je pomocny ..

+0

android.intent nie istnieje – pedja

+0

Zobacz zaktualizowane rozwiązanie, działa dobrze dla mnie. – ridoy

+0

to nadal nie działa. Odbiornik nie jest nadawany w żaden sposób – pedja

2

Czy odbiornik coraz transmisję w ogóle? Jeśli nie, być może zapomniałeś dodać uprawnienia do domeny PROCESS_OUTGOING_CALLS.

+0

W ogóle się nie nadaje, dodałem pozwolenie, ale wciąż nic – pedja

Powiązane problemy