• android144 360 快捷方式


    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;
        }
    
    }
  • 相关阅读:
    Linux c++ 试验4 一个输出整形类型数值问题
    Linux c++ 试验6 右值
    vi 常用命令
    ensp学习1 ensp无法运行启动问题解决
    Linux c++ 试验7 函数里定义的string不能返回成指针
    ensp学习2 ensp设置接口ip
    mmcblk0p0和sda1等等的含义
    大白话解释一下什么是NFT
    Docker实现Mysql主从复制
    docker安装redis
  • 原文地址:https://www.cnblogs.com/yaowen/p/5143720.html
Copyright © 2020-2023  润新知