Android结束通话并转到主屏幕

标签 android

我尝试制作一个 Android 程序,我可以通过单击按钮调用单个号码。工作正常,但当我结束通话时,模拟器会显示通话记录。取而代之的是,我的程序会返回到我创建的调用按钮所在的屏幕。我怎样才能做到这一点?我的代码现在是这样的

((Button) findViewById(R.id.soita)).setOnClickListener(
            new Button.OnClickListener() {
                @Override public void onClick(View arg0) {
String nro="9999999";
Intent intent1 = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+nro));
startActivity(intent1);
Intent intent2 = new Intent(Intent.CATEGORY_HOME);
startActivity(intent2);

最佳答案

尝试

Intent homeIntent = new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

关于Android结束通话并转到主屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1524111/

相关文章:

android - 将 Mat 对象中的图像转换为 Android 中的 float 组

java - Android - 在两个 Activity 之间传递数据得到 NullPointerException

android - 无法在 Android 11 上安装 CA 证书

Java公历转特定格式

android:layout_gravity ="center"无法设置标题栏中央的按钮?

Android 从 CSS 文件到字体的相对路径

java - 字体不适用于 CheckBox 和 Switch Android Studio 3

android - URLConnection getInputStream() 和 HttpEntity getContent() 之间的区别

android - 如何使用MediaCodec编码器获取RGB颜色格式的帧

android - React-native android 构建失败 : "...AAPT: error: resource android:attr/fontVariationSettings not found."