Traditional Culture Encyclopedia - Almanac 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);
- Previous article:Brief history of enterprise development of Zhejiang Jiaxin Silk Co., Ltd.
- Next article:20 19 at the beginning of the twelfth lunar month
- Related articles
- Wedding zodiac calendar daquan query
- Old almanac 1952 query table
- When did Spring Festival travel rush break out on February 3, 2022?
- What is the weather like in Urumqi today?
- Treatment of nocturnal emission with traditional Chinese medicine prescription
- What is the right gift for moving?
- Dreaming of my black pit, the omen of turning into a white pit
- 202 1.9.30 lunar calendar
- Is Tangshan city that never sleeps open now?
- What is the best regimen in Tomb-Sweeping Day?