<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    溫馨提示:您的每一次轉(zhuǎn)載,體現(xiàn)了我寫此文的意義!!!煩請您在轉(zhuǎn)載時(shí)注明出處http://m.tkk7.com/sxyx2008/謝謝合作!!!

    雪山飛鵠

    溫馨提示:您的每一次轉(zhuǎn)載,體現(xiàn)了我寫此文的意義!!!煩請您在轉(zhuǎn)載時(shí)注明出處http://m.tkk7.com/sxyx2008/謝謝合作!!!

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      215 Posts :: 1 Stories :: 674 Comments :: 0 Trackbacks

     

    package com.shortcut;
    import android.app.Activity;
    import android.content.ContentResolver;
    import android.content.Intent;
    import android.content.Intent.ShortcutIconResource;
    import android.database.Cursor;
    import android.net.Uri;
    import android.os.Bundle;

    public class AddShortCutActivity extends Activity {
        @Override
        
    public void onCreate(Bundle savedInstanceState) {
            
    super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
    boolean flag = IfaddShortCut();// 如果已經(jīng)創(chuàng)建,則不需要在創(chuàng)建
            if (flag == false{
                addShortCut();
            }

        }


        
    public void addShortCut() {
            Intent shortcut 
    = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
            
    // 設(shè)置屬性
            shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,getResources().getString(R.string.app_name));
            ShortcutIconResource iconRes 
    = Intent.ShortcutIconResource.fromContext(AddShortCutActivity.this, R.drawable.ic_launcher);
            shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON, iconRes);

            
    // 是否允許重復(fù)創(chuàng)建
            shortcut.putExtra("duplicate"false);
            Intent intent 
    = new Intent(Intent.ACTION_MAIN);
            intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setClass(AddShortCutActivity.
    this, AddShortCutActivity.class);
            
    // 設(shè)置啟動(dòng)程序
            System.out.println("createIcon");
            shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
            AddShortCutActivity.
    this.sendBroadcast(shortcut);
        }


        
    public boolean IfaddShortCut() {
            
    boolean isInstallShortcut = false;
            
    final ContentResolver cr = AddShortCutActivity.this.getContentResolver();
            
    // 本人的2.2系統(tǒng)是”com.android.launcher2.settings”,網(wǎng)上見其他的為"com.android.launcher.settings"
            final String AUTHORITY = "com.android.launcher2.settings";
            
    final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/favorites?notify=true");
            Cursor c 
    = cr.query(CONTENT_URI,
                    
    new String[] "title""iconResource" }"title=?",
                    
    new String[] { getString(R.string.app_name) }null);
            
    if (c != null && c.getCount() > 0{
                isInstallShortcut 
    = true;
            }

            
    return isInstallShortcut;
        }

    }

     

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package
    ="com.shortcut"
        android:versionCode
    ="1"
        android:versionName
    ="1.0" >

        
    <uses-sdk android:minSdkVersion="8" />

        
    <application
            
    android:icon="@drawable/ic_launcher"
            android:label
    ="@string/app_name" >
            
    <activity
                
    android:label="@string/app_name"
                android:name
    =".AddShortCutActivity" >
                
    <intent-filter >
                    
    <action android:name="android.intent.action.MAIN" />
                    
    <category android:name="android.intent.category.LAUNCHER" />
                
    </intent-filter>
                
    <intent-filter>  
                    
    <action android:name="android.intent.action.CREATE_SHORTCUT"></action>  
                
    </intent-filter>  
            
    </activity>
        
    </application>
        
    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS"/>   
        
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>  
    </manifest>

     

    Android Shortcut操作(一)
    http://www.eoeandroid.com/thread-92125-1-1.html

     Android Shortcut操作(二)
    http://www.eoeandroid.com/thread-92128-1-1.html
    posted on 2012-04-01 13:34 雪山飛鵠 閱讀(1953) 評(píng)論(1)  編輯  收藏 所屬分類: android

    Feedback

    # re: Android之快捷方式[未登錄] 2012-06-26 17:57 william
    怎么判斷是否添加shortcut,大哥,您的方法貌似不管用 !  回復(fù)  更多評(píng)論
      

    主站蜘蛛池模板: 国产精品成人啪精品视频免费| 亚洲AV日韩AV永久无码免下载| 日本特黄特色免费大片| 四虎影视免费永久在线观看| 国产亚洲美日韩AV中文字幕无码成人| 亚洲综合图色40p| 亚洲国产成人超福利久久精品| 涩涩色中文综合亚洲| 欧洲人成在线免费| 男女啪啪永久免费观看网站| 亚洲日韩乱码中文无码蜜桃| 无码A级毛片免费视频内谢| 亚洲av女电影网| 一级做a爰片久久毛片免费陪| 亚洲熟妇成人精品一区| 日本一区二区三区在线视频观看免费 | 久久精品国产亚洲一区二区| 特级淫片国产免费高清视频| 亚洲毛片免费视频| 久久精品免费观看| 一级毛片在线免费播放| 亚洲人成网站在线在线观看| 亚洲成a人片77777群色| 亚洲美女中文字幕| 久久精品视频亚洲| 国产亚洲精久久久久久无码| 亚洲中文字幕视频国产| 国产一区二区三区免费看| 四虎影视免费在线| 成年女人午夜毛片免费看| 欧美三级在线电影免费| 在线看片韩国免费人成视频| 永久看日本大片免费35分钟| 精品无码国产污污污免费网站| 日本免费A级毛一片| 国产日韩精品无码区免费专区国产| 美女被爆羞羞网站免费| 理论秋霞在线看免费| 无忧传媒视频免费观看入口| 激情吃奶吻胸免费视频xxxx| 免费的黄色的网站|