package cn.itcast.shortcut;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
public class CreateshortcutActivity extends Activity {
/** Called when the activity is first created. */
private static final String EXTRA_KEY = "cn.itcast.shortcut.CreateshortcutActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void click(View view){
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
/**
* An Intent representing the shortcut.
* The intent must contain three extras:
* SHORTCUT_INTENT (value: Intent),
* SHORTCUT_NAME (value: String), and
* SHORTCUT_ICON (value: Bitmap) or
* SHORTCUT_ICON_RESOURCE (value: ShortcutIconResource).
*/
Intent callintent = new Intent();
callintent.setAction(Intent.ACTION_CALL);
callintent.setData(Uri.parse("tel:123456"));
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, callintent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HAH");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, R.drawable.ic_launcher);
sendBroadcast(intent);
}
}
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
public class CreateshortcutActivity extends Activity {
/** Called when the activity is first created. */
private static final String EXTRA_KEY = "cn.itcast.shortcut.CreateshortcutActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void click(View view){
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
/**
* An Intent representing the shortcut.
* The intent must contain three extras:
* SHORTCUT_INTENT (value: Intent),
* SHORTCUT_NAME (value: String), and
* SHORTCUT_ICON (value: Bitmap) or
* SHORTCUT_ICON_RESOURCE (value: ShortcutIconResource).
*/
Intent callintent = new Intent();
callintent.setAction(Intent.ACTION_CALL);
callintent.setData(Uri.parse("tel:123456"));
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, callintent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HAH");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, R.drawable.ic_launcher);
sendBroadcast(intent);
}
}