android144 360 快捷方式

时间:2023-01-28 11:01:35
package com.example;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu; //权限:<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); /**
* 1 你想干什么事情
* 2 叫什么名字
* 3 长什么样子
*/
Intent dowhtIntent = new Intent();
//告诉系统哥想打电话
dowhtIntent.setAction(Intent.ACTION_CALL);
//给谁打电话
dowhtIntent.setData(Uri.parse("tel://110"));
//叫什么名字
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "哈哈");
//长什么样子
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON,
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, dowhtIntent);
sendBroadcast(intent);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }