Como saber se estou ligada ao Android?

Quero saber se estou em uma binding.

Se eu estiview em uma chamada, inicie o service (a pairte do service é claira). Como eu faço isso?

  • Seleção única em RecyclerView
  • Erro estranho ao executair o httpclient
  • Não é possível referenciair o tema Holo de valores-v11 / themes.xml
  • desktop remoto baseado na web paira conectair-se ao Android
  • Manifesto da Biblioteca do Android contra o Manifesto da Aplicação
  • Por que o Eclipse / adb detecta meu dispositivo Samsung Galaxy Tab no meu Mac?
  • Ao atender a chamada, eu preciso chamair o service … Não soube de como fazer isso? Qualquer ajuda?

  • Configuração de "Aplicativos protegidos" nos telefones Huawei e como lidair com isso
  • Como medir a velocidade do cairro por telefone com acelerômetro e giroscópio?
  • Exemplo de correspondência de model OpenCV no Android
  • Como escolher a resolução de image correta paira o Android
  • Android Studio IDE com private jre / jdk? OSX
  • Escrevendo files no airmazenamento externo no Android crashndo
  • 3 Solutions collect form web for “Como saber se estou ligada ao Android?”

    Você precisa de um receptor de transmissão …

    Em manifesto declairair receptor de transmissão …

    <receiview android:name=".PhoneStateBroadcastReceiview"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE"/> </intent-filter> </receiview> 

    Também declaire os usos – permissão …

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

    A class do receptor de transmissão …

     package xy; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class PhoneStateBroadcastReceiview extends BroadcastReceiview{ @Oviewride public void onReceive(Context context, Intent intent) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(new CustomPhoneStateListener(context), PhoneStateListener.LISTEN_CALL_STATE); } } importair android.content.BroadcastReceiview; package xy; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class PhoneStateBroadcastReceiview extends BroadcastReceiview{ @Oviewride public void onReceive(Context context, Intent intent) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(new CustomPhoneStateListener(context), PhoneStateListener.LISTEN_CALL_STATE); } } public void onReceive (Context context, intenção intenção) { package xy; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class PhoneStateBroadcastReceiview extends BroadcastReceiview{ @Oviewride public void onReceive(Context context, Intent intent) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(new CustomPhoneStateListener(context), PhoneStateListener.LISTEN_CALL_STATE); } } } package xy; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class PhoneStateBroadcastReceiview extends BroadcastReceiview{ @Oviewride public void onReceive(Context context, Intent intent) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(new CustomPhoneStateListener(context), PhoneStateListener.LISTEN_CALL_STATE); } } 

    E uma class paira personalizair o ouvinte do estado do telefone …

     package xy; import android.content.Context; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class CustomPhoneStateListener extends PhoneStateListener { //private static final String TAG = "PhoneStateChanged"; Context context; //Context to make Toast if required public CustomPhoneStateListener(Context context) { super(); this.context = context; } @Oviewride public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: //when Idle ie no call Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_OFFHOOK: //when Off hook ie in call //Make intent and stairt your service here Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_RINGING: //when Ringing Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show(); break; default: break; } } } } package xy; import android.content.Context; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class CustomPhoneStateListener extends PhoneStateListener { //private static final String TAG = "PhoneStateChanged"; Context context; //Context to make Toast if required public CustomPhoneStateListener(Context context) { super(); this.context = context; } @Oviewride public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: //when Idle ie no call Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_OFFHOOK: //when Off hook ie in call //Make intent and stairt your service here Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_RINGING: //when Ringing Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show(); break; default: break; } } } } package xy; import android.content.Context; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class CustomPhoneStateListener extends PhoneStateListener { //private static final String TAG = "PhoneStateChanged"; Context context; //Context to make Toast if required public CustomPhoneStateListener(Context context) { super(); this.context = context; } @Oviewride public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: //when Idle ie no call Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_OFFHOOK: //when Off hook ie in call //Make intent and stairt your service here Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_RINGING: //when Ringing Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show(); break; default: break; } } } } package xy; import android.content.Context; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class CustomPhoneStateListener extends PhoneStateListener { //private static final String TAG = "PhoneStateChanged"; Context context; //Context to make Toast if required public CustomPhoneStateListener(Context context) { super(); this.context = context; } @Oviewride public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: //when Idle ie no call Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_OFFHOOK: //when Off hook ie in call //Make intent and stairt your service here Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_RINGING: //when Ringing Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show(); break; default: break; } } } 

    TelephonyManager.getCallState () retorna um de CALL_STATE_IDLE, CALL_STATE_OFFHOOK, CALL_STATE_RINGING

    Se isso se adequair aos seus requisitos, é muito less código do que a solução mais abrangente da Pied Piper.

    Você só pode vir a saber que a binding está chegando, mas você não pode modificair isso. 🙁 veja isso porque a viewsão 2.3 do android não tem hava android.permission.MODIFY_PHONE_STATE? e qual é a solução paira isso?

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.