zoukankan      html  css  js  c++  java
  • Android 添加快捷方式

    package com.king.android.speical;
    import com.king.android.R;
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Parcelable;
    /**
     * 描述:快捷方式
     * 作者:Andy.Liu
     * 时间: 2012-7-16  下午11:59:07
     **/
    public class ShortCutActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent addShortCut;
    if(getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)){
    addShortCut = new Intent();
    addShortCut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, "发送邮件");
    //构建快捷方式中专门的图标
    Parcelable icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
    //添加快捷方式图标
    addShortCut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
    //构建快捷方式执行的intent
    Intent mailto = new Intent(Intent.ACTION_SENDTO,Uri.parse("mailto:xxx@xxx.com"));
    //添加快捷方式的intent
    addShortCut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mailto);
    //正常
    setResult(RESULT_OK, addShortCut);
    }else{
    //取消
    setResult(RESULT_CANCELED);
    }
    finish();
    }
    }
    /**  注意需要注册快捷方式
    <activity
    android:label="@string/app_name"
    android:name=".speical.WidgetActivity" >
    <intent-filter >
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <action android:name="android.intent.action.CREATE_LIVE_FOLDER"/>
    </intent-filter>
    </activity>
    */
  • 相关阅读:
    js 检测浏览器
    js获取url参数
    js 使用Math函数取得数组最大最少值
    js 取一定范围内的整数
    遍历文件夹内所有文件
    'weinre' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 解决方案
    解决图片缓存导致页面刷新无效果问题
    JAVA中的几种基本数据类型是什么,各自占用多少字节
    Mac终端git,svn提交代码步骤
    小程序分享链接功能
  • 原文地址:https://www.cnblogs.com/liuzenglong/p/2594559.html
Copyright © 2011-2022 走看看