回调的意图选择屏幕自定义项义项、回调、意图、自定

2023-09-03 21:30:28 作者:一辈子不换的好 值得用一辈子的

我的用例是从意向选配一个自定义的下载选项下载图像。我知道我可以通过添加一些code像下面添加自定义的选项:

 意图份额=新的意图(Intent.ACTION_SEND);
share.setType(text / plain的);
share.putExtra(Intent.EXTRA_TEXT,消息);

意图addIntent =; //任何你想要的

意向选择器=新的意图(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT,股);
chooser.putExtra(Intent.EXTRA_TITLE,标题);

意图[] intentArray = {addIntent};
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS,intentArray);
startActivity(选配);
 

我也有到位的功能,将下载的图像我。我的问题是,我可以检测到自定义选项,选择/点击的用户,然后设置一个回调到我的下载功能直接进行下载操作?

注:我不想在此过程中启动任何新的活动。只是在寻找指针就如何我可能设置一个回调在选择器这个自定义选项。

解决方案   

我能察觉的自定义选项,选择/点击的用户,然后设置一个回调到我的下载功能直接进行下载操作?

只有在Android 5.1+,如果你使用 createChooser() ,在那里你可以提供一个 IntentSender 的通知有关的选择.​​.....而且只有通过设置回调到我的下载功能直接进行下载操作你的意思是启动,做下载的活动。

否则,您将需要推出自己的选择器风格的用户界面,然后使用用户的选择,以便起草一个明确的意图,以便将用户请求的活动。

My use case is to download an image from a Custom Download option from Intent Chooser. I understand that I can add the custom option by adding some code like below :

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");       
share.putExtra(Intent.EXTRA_TEXT, message);

Intent addIntent = ;//whatever you want

Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, share );      
chooser.putExtra(Intent.EXTRA_TITLE, "title");

Intent[] intentArray =  {addIntent }; 
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivity(chooser);
如何自定义显示器没有的分辨率,例如 1440X900

I also have the the function in place which will download the image for me. My question is, Can I detect that the custom option was selected/clicked by the user and then set a callback to my download function directly and proceed with the download operation ?

Note : I do not want to launch any new activity during the process. Just looking for pointers on how I could possibly set a call back for this custom option in the chooser.

解决方案

Can I detect that the custom option was selected/clicked by the user and then set a callback to my download function directly and proceed with the download operation ?

Only on Android 5.1+, if you use the three-parameter flavor of createChooser(), where you can supply an IntentSender that is notified about the choice... and then only if by "set a callback to my download function directly and proceed with the download operation" you mean "launch an activity that does the download".

Otherwise, you would need to roll your own chooser-style UI, then use the user's choice to craft an explicit Intent to route the user to the requested activity.