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?

Different versions of the operating system and software are different, so setting desktop shortcuts may be different.

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);