【发布时间】:2019-03-28 03:44:14
【问题描述】:
我的应用程序只有MainActivity 和ImageView。
BroadcastReceiver 有效。当我连接 USB 时显示 Toast 消息。
现在,我需要最小化启动我的应用程序,并显示应用程序只连接了 USB 电缆。
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));
}
}
};
【问题讨论】:
-
请具体询问您在寻求什么帮助。问题是“如何最小化启动我的应用程序并仅显示连接了 USB 电缆的应用程序”?另外,请提供您已经尝试过的示例。
-
我有一个隐藏应用程序的按钮 (moveTaskToBack(true))。收到 USB 连接后,我需要再次打开应用程序。
标签: android android-intent broadcastreceiver android-task