如果应用程序崩溃,我想自动重启我的服务.我的想法是:
1:一个BroadcastReceiver,当apk崩溃并自动重启服务时
if("android.intent.action.SOMETHING".equals(intent.getAction()))
{
Intent serviceLauncher = new Intent(context, Service.class);
context.startService(serviceLauncher);
}
Run Code Online (Sandbox Code Playgroud)
2:带有uncaughtException(),但我不知道要处理它
我从 AOSP 构建的 Android 模拟器有问题。
我的步骤是:
$ repo sync -j8
$ source build/envsetup.sh
$ lunch --> chose 22. aosp_x86_64-eng
$ make -j8
$ set_stuff_for_environment
$ emulator
Run Code Online (Sandbox Code Playgroud)
然后模拟器启动,但一直黑屏,很长一段时间没有响应。我还尝试了其他目标,例如 1. aosp_arm-eng
其他所有模拟器都启动(通过 AVD Manager 或 Android Studio)像往常一样工作。
我使用 macOS 10.14.6
我以编程方式创建了一个按钮,并为其提供了ID和标签.
Button button = new Button(this);
button.setId(i);
button.setTag(anotherID);
Run Code Online (Sandbox Code Playgroud)
我是一个柜台.
现在我想改变这个按钮的背景,但我无法找到它
findViewByID(ID)
Run Code Online (Sandbox Code Playgroud)
要么
findViewWithTag(anotherID)
Run Code Online (Sandbox Code Playgroud)
我使用ID和anotherID我创建按钮的值,但我只获得NullPointerExceptions.我没有从XML文件中获取任何ID,因为我以编程方式创建按钮.有谁知道我怎么能处理这个?