gpt4 book ai didi

android - 使用 Intent.createChooser 关闭 Activity

转载 作者:行者123 更新时间:2023-11-29 17:16:32 25 4
gpt4 key购买 nike

我正在使用 Intent.createChooser 来共享内容。然后共享 Intent.createChooser 对话框出现并且工作正常但是当我按下后退按钮关闭对话框时,它完成 Activity 。我想阻止 Activity 关闭只是想关闭 Intent.createChooser 对话框。onclick 事件在 Recyclerview 中。

 shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//align the selection to the
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, items.get(position).getShareUrl());
context.startActivity(Intent.createChooser(shareIntent, "Share with"));
}
});


<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />

<supports-screens>
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"
</supports-screens>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:launchMode="singleTop"
android:noHistory="true"
android:screenOrientation="portrait"
android:showAsAction="ifRoom|withText">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

最佳答案

从 list 文件中的 MainActivity 中删除 android:noHistory="true"

关于android - 使用 Intent.createChooser 关闭 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38606251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com