Re: [android-developers] BroadCastReceiver + Service + KeyEvent (Foreground)

2016-11-18 Thread Steve Gabrilowitz
For security reasons, a broadcast receiver will not activate until after
the user has started an activity, could this be your issue?  I notice there
is no activity in the manifest segment you posted.

On Nov 17, 2016 12:26 PM, "MrEdusi"  wrote:

> My BroadcastReceiver will not start I will post the code below if someone
> can point me the error thank you android:name="android.permission.INTERNET"
> />
>
>
> 
> android:enabled="true"
> android:name="BroadcastReceiver"
> android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
>
>
> 
>
> 
>
>
> 
>
> 
>
> 
>
> 
> 
>
>
>
>
> public class BroadcastReceiver extends android.content.BroadcastReceiver {
>
> @Override
> public void onReceive(Context context, Intent intent) {
> Intent i = new Intent(context, ComandosDoControle.class);
> Log.d("Iniciado","BroadcastReceiver");
> context.startService(i);
>
> }
>
>
>
> }
>
>
> ublic class ComandosDoControle extends Service
> implements View.OnKeyListener{
>
> public int onStartComand(Intent intent, int flags, int startid){
> return Service.START_STICKY;
> }
>
>
> //ACESSO A OUTROS APPS
> @Override
> public IBinder onBind(Intent intent) {
> return null;
> }
>
> @Override
> public boolean onKey(View v, final int keyCode, final KeyEvent event) {
>
> new Thread(new Runnable() {
>
> public void run() {
>
> if (keyCode == event.KEYCODE_ENTER) {
>
> Log.d("Clicado","ComandosDoControle");
>
>   //  Toast.makeText(getApplicationContext(), "Botão do 
> controle pegou!", Toast.LENGTH_LONG).show();
>
> }else{
>
>// Toast.makeText(getApplicationContext(), "Botão do 
> controle não pegou!", Toast.LENGTH_LONG).show();
> }
> }
> }).start();
>
> return true;
>
> }
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/android-developers/1f923fba-c9be-4272-9864-
> 5b087a1c2020%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CABfabRhtxcKTdT0k8eLTaVJefZrE86qsbAnxghzbt29XAceA3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] BroadCastReceiver + Service + KeyEvent (Foreground)

2016-11-17 Thread MrEdusi
My BroadcastReceiver will not start I will post the code below if someone 
can point me the error thank you






















public class BroadcastReceiver extends android.content.BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, ComandosDoControle.class);
Log.d("Iniciado","BroadcastReceiver");
context.startService(i);

}



}


ublic class ComandosDoControle extends Service
implements View.OnKeyListener{

public int onStartComand(Intent intent, int flags, int startid){
return Service.START_STICKY;
}


//ACESSO A OUTROS APPS
@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public boolean onKey(View v, final int keyCode, final KeyEvent event) {

new Thread(new Runnable() {

public void run() {

if (keyCode == event.KEYCODE_ENTER) {

Log.d("Clicado","ComandosDoControle");

  //  Toast.makeText(getApplicationContext(), "Botão do 
controle pegou!", Toast.LENGTH_LONG).show();

}else{

   // Toast.makeText(getApplicationContext(), "Botão do 
controle não pegou!", Toast.LENGTH_LONG).show();
}
}
}).start();

return true;

}





-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/1f923fba-c9be-4272-9864-5b087a1c2020%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.