我遇到了这个奇怪的崩溃。这似乎是 AlarmManager.set() 造成的,但我不明白如何也不明白为什么。
堆栈跟踪:
Fatal Exception: java.lang.RuntimeException: Unable to create application com.rotem.appmanager.app.MainApplication: java.lang.SecurityException: get application info: Neither user 1010069 nor current process has android.permission.INTERACT_ACROSS_USERS.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4560)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:974)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
Caused by java.lang.SecurityException: get application info: Neither user 1010069 nor current process has android.permission.INTERACT_ACROSS_USERS.
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.IAlarmManager$Stub$Proxy.set(IAlarmManager.java:215)
at android.app.AlarmManager.setImpl(AlarmManager.java:409)
at android.app.AlarmManager.set(AlarmManager.java:208)
at com.rotem.appmanager.app.DailyAppTasksHelper.scheduleNextDailyAlarm(SourceFile:81)
Run Code Online (Sandbox Code Playgroud)
编码:
Context context = MainApplication.getAppContext();
Intent intent = new Intent(context, …
Run Code Online (Sandbox Code Playgroud) 我有以下bool.xml
文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="some_key">false</bool>
</resources>
Run Code Online (Sandbox Code Playgroud)
当我尝试在以下位置使用此值时AndroidManifest
:
<activity
android:name=".ui.activities.SomeActivity"
android:enabled="@bool/some_key"
... >
...
</activity>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
无法将字符串“@bool/some_key”转换为目标类“boolean”
我正在使用 Android Studio 2.2.3
我想测试我的应用在 Android Go 上的表现。
根据这篇文章:https : //developer.android.com/develop/quality-guidelines/building-for-billions-device-capacity.html#androidgo
我了解需要设置以下条件:
<uses-feature android:name="android.hardware.ram.low" android:required="true">
到应用程序清单。如何判断我的应用是否在 Android Go 模式下运行?
我创建了一个具有以下配置的模拟器:
名称:Andorid_go_API_27
CPU/ABI:Google APIs Intel Atom (x86)
路径:C:\Users\rotem.matityahu.android\avd\Andorid_go_API_27.avd
目标:google_apis [Google APIs](API 级别 27)
皮肤:1080x1920
SD 卡:100 MiB
hw.dPad:没有
hw.lcd.height: 1920
runtime.network.speed:满
hw.加速度计:是的
hw.device.name:新设备 1
vm.heapSize:256
skin.dynamic:是的
hw.device.manufacturer:用户
hw.lcd.width: 1080
hw.gps:是的
hw.initialOrientation:纵向
skin.path.backup: _no_skin
image.androidVersion.api: 27
hw.audioInput: 是
image.sysdir.1: system-images\android-27\google_apis\x86\
tag.id: google_apis
showDeviceFrame: 没有
hw.camera.back:模拟
hw.mainKeys: 没有
AvdId:Andorid_go_API_27
hw.camera.front:模拟
hw.lcd.密度:480
avd.ini.displayname: Andorid go API 27 …
我有一个具有多种风格的 Android 应用程序,并且我只希望特定风格包含特定的代码段。更具体地说,我想使用第三方库并仅以特定的方式添加该库的初始化代码。
public class MainApplication
extends Application {
@Override
public void onCreate() {
super.onCreate();
//The library is only included in the build of specific flavors, so having this code in other flavors will not compile
//I want the following code only to be included in the flavors that include the library
SomeLibrary.init();
//other code that is relevant for all flavors
...
}}
Run Code Online (Sandbox Code Playgroud)