当我在开发者模式下通过USB切换安装时:
这有什么解决方案吗?
我一直在搜索关闭MIUI优化,但仍然无法正常工作.我无法以这种方式通过Android Studio调试我的应用程序......
我的应用程序有一项服务和一项活动。从服务中,使用以下代码调用活动:
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
即使没有标志,通常活动窗口也会以其正确的布局显示。但是,在搭载 Android 7 的小米红米 Note 4 上,不显示活动布局。我只在 logcat 上看到以下行:
I/Timeline: Timeline: Activity_launch_request time:281438674 intent:Intent { flg=0x30000000 cmp=com.test.app/.MainActivity }
我相信这不是 Android 7 (API 24) 问题,因为在另一台装有 Android 7 的设备上,服务可以成功启动活动。我猜想,MIUI 正在阻止从服务中启动该活动。
我尝试更改清单中活动的定义方式。我还尝试了几种不同的标志。我所有的测试都失败了。我无法成功开始活动。最糟糕的问题是日志中没有错误/异常。
请对此有任何想法吗?
我没有收到BOOT_COMPLETE
我的小米Redmi 2 Prime手机的广播.
我BroadcastReciever
是---
public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Setting singleAlarm
SingleAlarmHandler.getInstance().setAlarm(context);
try {
// Sending System Setting broadcast
String offDate = SharedPrefrencesHandler.getInstance(context).readString(SharedPrefrencesConstants.SWITCH_OFF_DATE);
int type = SystemSettingsType.PHONE_SWITCH_ON_OFF.getNumericType();
if (offDate == null)
offDate = "";
SystemSettingsHandler.getSystemSettingsHandler().makeSystemSettingsCall(context, type, offDate);
SharedPrefrencesHandler.getInstance(context).removePrefrence(SharedPrefrencesConstants.SWITCH_OFF_DATE);
} catch (Exception e) {
Log.e(ChaseForceApplication.TAG, e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
和清单:
<receiver
android:name=".broadcastlisteners.OnBootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
经许可:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Run Code Online (Sandbox Code Playgroud)
现在我没有在我的小米Redmi 2 Prime手机中获得BOOT …
我在真实设备上从 android 10 - android Q - MIUI 11 的后台启动活动时遇到问题。在此线程中:在 android 10 中启动活动背景我找到了如何在 Android 10 上执行此操作的信息,以及在模拟器上一切正常的信息。
我在使用 Android 10 (MIUI 11) 的小米米 9T Pro 上对此进行了测试,似乎这不起作用。
在 logcat 我有以下日志:
-W/ActivityTaskManager: Background activity start for com.com.app allowed because SYSTEM_ALERT_WINDOW permission is granted.
-D/ActivityTaskManagerServiceInjector: MIUILOG- Permission Denied Activity : Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.android.chrome cmp=com.android.chrome/com.google.android.apps.chrome.Main } pkg : com.com.app uid : 10283 tuid : 10052
Run Code Online (Sandbox Code Playgroud)
为什么这不适用于小米设备?
编辑:
我找到了解决方案。在 MIUI 中,应该打开额外的权限。它被称为:在后台运行时显示弹出窗口。这是使用此权限显示窗口的代码:
首先,我正在检查用户是否在手机上安装了 MIUI:
public static boolean isMiUi() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
} …
Run Code Online (Sandbox Code Playgroud) 我的应用程序的主要功能是从远程服务器发送的推送通知消息。我使用 FCM 作为消息传递服务。我的问题是小米米 9 Lite (Android 9/MIUI 11) 上的通知没有任何声音。但是,在小米红米 Note 5 (Android 9/MIUI 10) 上声音工作正常,在三星 Galaxy S7 Edge (Android 8) 上也能正常工作。我创建了 MessagingService,它扩展了 FirebaseMessagingService 和文档中编写的通知通道。
这是我的代码:
public class MessagingService extends FirebaseMessagingService {
private static String channelId;
private NotificationManager notificationManager;
private NotificationChannel notificationChannel;
private NotificationCompat.Builder notificationBuilder;
private MessagesViewModel viewModel;
public MessagingService() { }
@Override
public void onCreate() {
super.onCreate();
channelId = getResources().getString(R.string.default_notification_channel_id);
notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
final Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationBuilder = new NotificationCompat.Builder(this, channelId);
notificationBuilder.setSmallIcon(R.raw.metrial_message_icon);
notificationBuilder.setAutoCancel(false);
notificationBuilder.setSound(soundUri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) …
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种直接从我的应用程序在MIUI App Notification Settings屏幕中打开的方法 .就像这样:设置 - >已安装的应用 - > MY_APP - >通知.
如何构建打开此屏幕的意图?
这与Oreo中添加的Notification Channels Manager不同 - MIUI(Xiaomi)有自己的通知管理器.
我无法在 MIUI 11 redmi note 6 pro mobile 中开始活动,出现以下错误:
com.android.server.am.ExtraActivityManagerService: MIUILOG- 权限被拒绝活动
我找到了一些解决方案,例如打开“后台启动”权限。我在 MIUI 11 上找不到这样的东西。从字面上看,我不知道这个问题。提前致谢。
当应用程序在后台并且屏幕被锁定时,我无法启动活动,没有异常或警告,只是没有调用 onCreate()。我一直在努力解决这个问题,我想我终于找到了它的根源。日志中有一行:
D/com.android.server.am.ExtraActivityManagerService: MIUILOG- Permission Denied Activity KeyguardLocked: Intent { flg=0x14010000 cmp=com.trueconf.videochat/com.trueconf.gui.activities.Call (has extras) } pkg : com.trueconf.videochat uid : 10634
Run Code Online (Sandbox Code Playgroud)
这就是我无法开始活动的原因吗?另外,我该如何解决这个问题,我应该禁用键盘锁还是什么?
将我的小米 Mi Mix 2 从 miui 10 更新到 miui 11(以及从 android 8 到 9,api 级别 26 -> 28)后,问题出现了。当我使用 Android Studio 将调试器附加到我的应用程序时,它开始执行得非常慢(一个活动自行加载长达 15 秒(原文如此!),通常为 ~1-2 秒)。当我在模拟器上运行我的应用程序时(当然是在调试模式下),一切正常且顺利。在更新之前,它在调试期间在我的手机上运行良好。问题是:这是 android 9 硬件的正常行为还是我的手机有问题?我没有找到任何具有类似问题的线程。
我正在编写一个需要在后台启动活动的 Android 应用程序。
在小米设备上,我的应用程序必须接受“在后台运行时显示弹出窗口”权限才能执行此操作。
不过不知道什么时候授予这个权限,引导用户接受。有没有什么解决方案来检查此权限是否被授予?
谢谢