更改 Android 呼叫屏幕
我正在开发一个应用程序,可以更改 Android 操作系统的呼叫屏幕 UI。现在我知道,我无法替换 UI,我可以将自定义活动覆盖在它上面。这就是我尝试做的。
我可以通过 android.intent.action.PHONE_STATE
接收响铃状态的意图,它工作正常,但是当我启动自己的 Activity 时,它会转到后台,Android 的本机 UI 会替换它。有什么办法可以改变这一点吗?我不想执行 Thread.sleep() (尽管作为最后的手段我可能不得不这样做)。
这是代码:
Android Manifest:
<receiver android:name=".callIntentReceiver">
<intent-filter >
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
callIntentReceiver.java:
public class callIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("SmartCaller","Working sort of");
Intent intent = new Intent(context, mainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
}
I'm developing an app that would change the Call screen UI of the android OS. Now i know, I can't replace the UI, i can overlay my custom activity over it. So that's what i tried to do.
I can receive the intent by android.intent.action.PHONE_STATE
of the ringing state and it works fine however when i launch my own activity it goes to the background and android's native UI replaces it. Is there anyway to change that? I don't want to do Thread.sleep()
(though as a last resort I might have to).
Here is the code:
Android Manifest:
<receiver android:name=".callIntentReceiver">
<intent-filter >
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
callIntentReceiver.java:
public class callIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("SmartCaller","Working sort of");
Intent intent = new Intent(context, mainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论