Traditional Culture Encyclopedia - Weather inquiry - I deleted the shortcut of weather forecast that comes with Android phone. How can I make it right?
I deleted the shortcut of weather forecast that comes with Android phone. How can I make it right?
But in the end, you can create shortcuts by developing tools and writing code directly:
1. The code for creating an icon is as follows:
& lt activities? android:name= "。 MainActivity " >
& lt intention filter & gt
& lt Action? Android:name = " Android . intent . action . create _ SHORTCUT "/& gt;
& lt/intent-filter & gt;
& lt/activity & gt;
The following are shortcuts to creating a desktop:
2. The next step is to set the icon, name, event and other properties of the shortcut.
Public? Invalid? createShortCut(){
Intention? Add a shortcut;
If (get intent()。 getaction()。 Equal to (intention. Action _ create _ shortcut)){// Determines whether a shortcut needs to be added.
Add shortcuts? =? New? intent();
addShortCut.putExtra(Intent。 EXTRA _ SHORTCUT _ NAME? ,? "Shortcuts"); //The name of the shortcut
Packed? Icon? =? Short stratum corneum resources. fromContext(this,? r . drawable . icon); //displayed picture
addShortCut.putExtra(Intent。 Extra _ Shortcuts _ Icons _ Resources,? Icon); //Define the activity activated by the shortcut and the intention to be executed.
addShortCut.putExtra(Intent。 EXTRA _ SHORTCUT _ INTENT,? New? intent());
setResult(RESULT_OK,? add shortcut); //OK, generate
} Otherwise {//Cancel
setResult(RESULT _ CANCELED);
}
}
3. Add another icon to the desktop.
Intention? Shortcut? =? New? intent(" com . Android . launcher . action . install _ SHORTCUT "); //The name of the shortcut
shortcut.putExtra(Intent。 Extra shortcut name? getString(r . string . app _ name));
Shortcut.putExtra("duplicate ",false); ? //Duplicate creation is not allowed.
//Specifies that the current activity is an object started by a shortcut key:? Like what? everest.video.VideoPlayer
//Note:? The second parameter of ComponentName must add a dot (. ), otherwise the shortcut key cannot start the corresponding program.
//component name? comp? =? New? component name(this . get package name(),? "."+this . getlocalclassname());
//shortcut . put extra(Intent。 EXTRA _ SHORTCUT _ INTENT,? New? Intent (intention). ACTION_MAIN)。 set component(comp));
shortcut.putExtra(Intent。 EXTRA _ SHORTCUT _ INTENT,? New? Intent(this,wxentryactivity . class)); //Shortcut icon
ShortcutIconResource? iconRes? =? Intention. Short stratum corneum resources. fromContext(this,? r . draw able . IC _ launcher);
shortcut.putExtra(Intent。 Extra _ Shortcuts _ Icons _ Resources,? iconRes);
Send a broadcast (shortcut);
- Related articles
- * * * What's the reason why you died halfway while enjoying an umbrella?
- Where is the National Astronomical Observatory of Chinese Academy of Sciences?
- Wind shear (danger of weather phenomena)
- How does oppo r9 join the weather?
- Where is suitable for providing for the aged?
- How to do gum swelling and pain? Is there any way?
- Where is Jiangnan? Which city?
- Where do you think the funny version of Tik Tok· Young is? Who sang Tik Tok· Young for you?
- How to remedy the bud after grape dormancy is not enough?
- Boys in Myanmar all wear skirts. What does this have to do with local culture?