My application only have MainActivity
with a ImageView
.
BroadcastReceiver
works. The Toast Message is displayed When I connect USB.
Now, I need start my application minimized and show the application only the USB cable was connected.
BroadcastReceiver broadcast_reciever = new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent intent) {
String action = intent.getAction();
if (action.equals("usb_detect")) {
Toast.makeText(arg0,"Atenção!",Toast.LENGTH_SHORT).show();
finish();
startActivity(getIntent());
//startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER));
}
}
};
Manifest is here: https://i.stack.imgur.com/sa3Pe.jpg