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

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

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

    溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.tkk7.com/sxyx2008/謝謝合作!!!

    雪山飛鵠

    溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.tkk7.com/sxyx2008/謝謝合作!!!

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      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();// 如果已經創建,則不需要在創建
            if (flag == false{
                addShortCut();
            }

        }


        
    public void addShortCut() {
            Intent shortcut 
    = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
            
    // 設置屬性
            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);

            
    // 是否允許重復創建
            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);
            
    // 設置啟動程序
            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系統是”com.android.launcher2.settings”,網上見其他的為"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 雪山飛鵠 閱讀(1951) 評論(1)  編輯  收藏 所屬分類: android

    Feedback

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

    主站蜘蛛池模板: 中文字幕在线观看免费视频| 好久久免费视频高清| 四虎免费大片aⅴ入口| 亚洲国产理论片在线播放| 最近2019免费中文字幕视频三| 亚洲国产精品无码久久久秋霞2| 久久久受www免费人成| 亚洲熟妇av一区二区三区| 好男人资源在线WWW免费| 在线亚洲午夜理论AV大片| a在线观看免费视频| 亚洲爱情岛论坛永久| 最近免费中文字幕高清大全| 亚洲日韩中文字幕天堂不卡| 两性刺激生活片免费视频| 亚洲真人无码永久在线观看| 吃奶摸下高潮60分钟免费视频| 大片免费观看92在线视频线视频| 亚洲综合色视频在线观看| 你是我的城池营垒免费看| 337p日本欧洲亚洲大胆色噜噜| 1000部拍拍拍18勿入免费视频软件 | 黄色毛片免费网站| 亚洲香蕉成人AV网站在线观看| 日韩精品免费在线视频| 亚洲宅男天堂a在线| 国产美女无遮挡免费视频| 成人毛片100免费观看| 亚洲综合在线成人一区| 四虎影视在线永久免费看黄| 中文字幕永久免费| 国产精品亚洲综合五月天| 免费在线观看一级毛片| 久久久久久AV无码免费网站| 亚洲色成人网站WWW永久四虎| 亚洲国产精品尤物YW在线观看| 三年片在线观看免费观看大全动漫| 亚洲jizzjizz在线播放久| 国产亚洲大尺度无码无码专线 | 亚洲va在线va天堂va四虎| 超pen个人视频国产免费观看|