Android - creating and running shortcuts

These are really two questions.

1. I would like to launch a menu so that you can create a shortcut similar to the way the code below launches a menu where you can create a shortcut in the usual way.

Intent pickIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT); startActivityForResult(pickIntent, 5); 

Only when I use the code above and I check the data does it seem to contain no data. I'm not sure if I need the following permissions, but I added it to my manifest anyway:

 <uses-permission> android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> 

I want to save the data used to launch the shortcut in a file so that I can run the shortcut from my application.

2 .. How can I run the quick access code, it's basically like launching an intent with extra flags, etc.

I saw an application that can do what I just said, and I was able to view one of the files stored on my SD card:

Below is an example of what I found:

 Intent;action=com.sonyericsson.android.camera.action.FRONT_STILL_IMAGE_CAMERA; component=com.sonyericsson.android.camera/.CameraActivity; S.com.sonyericsson.camera.intent.extra.CAPTURING_MODE=front_normal; end{[SName}]Front camera 

I am sure that the above launches a shortcut that opens the camera application, and he is ready to take a picture from the front camera, but not sure how to launch it.

Any help is greatly appreciated.

+4
source share
1 answer

After much searching, I found what I was looking for:

Hidden for string:

 String uri = intent.toURI().ToString() 

Save this whenever you want, file, sqlite, etc.

To return it and launch the intention, do

 try { startActivity(Intent.getIntent(uri)); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } 

Found out how to do this: Any workaround to keep intent in settings?

So what was like

 Intent;action=com.sonyericsson.android.camera.action.FRONT_STILL_IMAGE_CAMERA; component=com.sonyericsson.android.camera/.CameraActivity; S.com.sonyericsson.camera.intent.extra.CAPTURING_MODE=front_normal; end{[SName}]Front camera 

should look like this:

 try {startActivity(Intent.getIntent("#Intent;action=com.sonyericsson.android.camera.action.FRONT_STILL_IMAGE_CAMERA;component=com.sonyericsson.android.camera/.CameraActivity;S.com.sonyericsson.camera.intent.extra.CAPTURING_MODE=front_normal;end")); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } 
+8
source

Source: https://habr.com/ru/post/1443097/


All Articles