我有一个要求,当用户单击我的Flutter应用程序中的按钮时,我会将用户重定向到我无权访问的其他应用程序。然后,用户需要从该应用程序共享文件。我使用意图过滤器在ReceiveIntent.java类中接收文件
AndroidManifest.xml
<activity
android:label="SampleApp"
android:exported="true"
android:name="com.sampleapp.example.ReceiveIntent"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/zip"/>
</intent-filter>
</activity>
Java代码
private void handleIntent(Intent intent){
// Get intent, action and MIME type
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.equalsIgnoreCase("application/zip")) {
handleSharedZIP(intent); // Handle text being sent
} else if (type.startsWith("image/*")) {
handleSendImage(intent); // Handle single image being sent
}
}
}
private void handleSharedZIP(Intent intent) {
try {
// pass the the path received from the intent filters to password unlock screen. So
that we can verify and Extract the data there.
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
sharedZIP = uri.toString();
sharedZIPMethodChannel.invokeMethod("getSharedZIP",sharedZIP);
}catch (Exception e){
e.printStackTrace();
e.getMessage();
Log.d("error",e.getMessage().toString());
}
}
一切正常,直到这里。但是我不想从这里将用户重定向到密码解锁屏幕。 我尝试了“方法通道”,但没有启动该方法通道的flutter小部件
感谢您的帮助。
预先感谢。