1..Launcher是什么?
1.1Launcher是系统启动后加载的第一个应用程序
1.2Launcher是其他应用程序的入口
2.Launcher的构成:
3. 主体四大组件的区别:
ShortCut:应用程序的快捷方式
Appwidget:桌面小部件,图形不规则
LiveFolder:文件夹
以ContentProvider的形式展示应用中特定数据的集合
WallPaper:壁纸
预览图如下:
4.通过按钮添加或者删除应用程序的快捷方式Demo:
Intent.EXTRA_SHORTCUT_INTENT,
布局文件:
Main.xml
-
<?xmlversion="1.0"encoding="utf-8"?>
-
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent"
-
android:orientation="vertical">
-
-
<TextView
-
android:layout_width="fill_parent"
-
android:layout_height="wrap_content"
-
android:text="@string/hello"/>
-
-
<Button
-
android:id="@+id/BT_InstallShortCurt"
-
android:layout_width="match_parent"
-
android:layout_height="wrap_content"
-
android:text="InstallShortCurt"/>
-
-
<Button
-
android:id="@+id/BT_UnInstallShortCurt"
-
android:layout_width="match_parent"
-
android:layout_height="wrap_content"
-
android:text="UnInstallShortCurt"/>
-
-
</LinearLayout>
清单文件Mainifest.xml
-
<?xmlversion="1.0"encoding="utf-8"?>
-
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
-
package="com.itheima.lancher"
-
android:versionCode="1"
-
android:versionName="1.0">
-
-
<uses-sdkandroid:minSdkVersion="8"/>
-
<!--该权限为系统自定义权限-->
-
<uses-permissionandroid:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
-
<uses-permissionandroid:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
-
<application
-
android:icon="@drawable/ic_launcher"
-
android:label="@string/app_name">
-
<activity
-
android:name=".LancherDemoActivity"
-
android:label="@string/app_name">
-
<intent-filter>
-
<actionandroid:name="android.intent.action.MAIN"/>
-
-
<categoryandroid:name="android.intent.category.LAUNCHER"/>
-
</intent-filter>
-
</activity>
-
-
<activityandroid:name=".ShortCutActivity">
-
<intent-filter>
-
<!-拦截添加快捷方式,显示土司->
-
<actionandroid:name="android.intent.action.CREATE_SHORTCUT"/>
-
</intent-filter>
-
</activity>
-
</application>
-
-
</manifest>
LancherDemoActivity;
-
importandroid.app.Activity;
-
importandroid.content.ComponentName;
-
importandroid.content.Intent;
-
importandroid.os.Bundle;
-
importandroid.view.View;
-
importandroid.view.View.OnClickListener;
-
importandroid.widget.Button;
-
-
publicclassLancherDemoActivityextendsActivity{
-
privateButtonbutton1;
-
privateButtonbutton2;
-
-
publicvoidonCreate(BundlesavedInstanceState){
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.main);
-
button1=(Button)findViewById(R.id.BT_InstallShortCurt);
-
button2=(Button)findViewById(R.id.BT_UnInstallShortCurt);
-
button1.setOnClickListener(newOnClickListener(){
-
-
publicvoidonClick(Viewv){
-
addShortCurt2DeskTop();
-
}
-
-
-
-
-
privatevoidaddShortCurt2DeskTop(){
-
Intentshortcut=newIntent("com.android.launcher.action.INSTALL_SHORTCUT");
-
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"TonyAutoShortCut");
-
shortcut.putExtra("duplicate",false);
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(LancherDemoActivity.this,R.drawable.beauty));
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,newIntent(LancherDemoActivity.this,LancherDemoActivity.class).setAction(<spanstyle="color:#FF0000;">"com.android.action.test"</span>));
-
-
-
sendBroadcast(shortcut);
-
}
-
});
-
-
-
-
-
button2.setOnClickListener(newOnClickListener(){
-
publicvoidonClick(Viewv){
-
deleteShortCurt2DeskTop();
-
}
-
-
privatevoiddeleteShortCurt2DeskTop(){
-
Intentshortcut=newIntent("com.android.launcher.action.UNINSTALL_SHORTCUT");
-
-
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"TonyAutoShortCut");
-
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,newIntent(LancherDemoActivity.this,LancherDemoActivity.class).setAction(<spanstyle="color:#FF0000;">"com.android.action.test"</span>));
-
sendBroadcast(shortcut);
-
}
-
});
-
-
-
}
-
}
注意事项: 在设置 EXTRA_SHORTCUT_INTENT时,添加和删除快捷方式的这个INTENT对象的ACTION属性必须设置为相同内容,才能声明删除和创建的快捷方式是一个,进行绑定,
否则删除无法生效
1..Launcher是什么?
1.1Launcher是系统启动后加载的第一个应用程序
1.2Launcher是其他应用程序的入口
2.Launcher的构成:
3. 主体四大组件的区别:
ShortCut:应用程序的快捷方式
Appwidget:桌面小部件,图形不规则
LiveFolder:文件夹
以ContentProvider的形式展示应用中特定数据的集合
WallPaper:壁纸
预览图如下:
4.通过按钮添加或者删除应用程序的快捷方式Demo:
Intent.EXTRA_SHORTCUT_INTENT,
布局文件:
Main.xml
-
<?xmlversion="1.0"encoding="utf-8"?>
-
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent"
-
android:orientation="vertical">
-
-
<TextView
-
android:layout_width="fill_parent"
-
android:layout_height="wrap_content"
-
android:text="@string/hello"/>
-
-
<Button
-
android:id="@+id/BT_InstallShortCurt"
-
android:layout_width="match_parent"
-
android:layout_height="wrap_content"
-
android:text="InstallShortCurt"/>
-
-
<Button
-
android:id="@+id/BT_UnInstallShortCurt"
-
android:layout_width="match_parent"
-
android:layout_height="wrap_content"
-
android:text="UnInstallShortCurt"/>
-
-
</LinearLayout>
清单文件Mainifest.xml
-
<?xmlversion="1.0"encoding="utf-8"?>
-
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
-
package="com.itheima.lancher"
-
android:versionCode="1"
-
android:versionName="1.0">
-
-
<uses-sdkandroid:minSdkVersion="8"/>
-
<!--该权限为系统自定义权限-->
-
<uses-permissionandroid:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
-
<uses-permissionandroid:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
-
<application
-
android:icon="@drawable/ic_launcher"
-
android:label="@string/app_name">
-
<activity
-
android:name=".LancherDemoActivity"
-
android:label="@string/app_name">
-
<intent-filter>
-
<actionandroid:name="android.intent.action.MAIN"/>
-
-
<categoryandroid:name="android.intent.category.LAUNCHER"/>
-
</intent-filter>
-
</activity>
-
-
<activityandroid:name=".ShortCutActivity">
-
<intent-filter>
-
<!-拦截添加快捷方式,显示土司->
-
<actionandroid:name="android.intent.action.CREATE_SHORTCUT"/>
-
</intent-filter>
-
</activity>
-
</application>
-
-
</manifest>
LancherDemoActivity;
-
importandroid.app.Activity;
-
importandroid.content.ComponentName;
-
importandroid.content.Intent;
-
importandroid.os.Bundle;
-
importandroid.view.View;
-
importandroid.view.View.OnClickListener;
-
importandroid.widget.Button;
-
-
publicclassLancherDemoActivityextendsActivity{
-
privateButtonbutton1;
-
privateButtonbutton2;
-
-
publicvoidonCreate(BundlesavedInstanceState){
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.main);
-
button1=(Button)findViewById(R.id.BT_InstallShortCurt);
-
button2=(Button)findViewById(R.id.BT_UnInstallShortCurt);
-
button1.setOnClickListener(newOnClickListener(){
-
-
publicvoidonClick(Viewv){
-
addShortCurt2DeskTop();
-
}
-
-
-
-
-
privatevoidaddShortCurt2DeskTop(){
-
Intentshortcut=newIntent("com.android.launcher.action.INSTALL_SHORTCUT");
-
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"TonyAutoShortCut");
-
shortcut.putExtra("duplicate",false);
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(LancherDemoActivity.this,R.drawable.beauty));
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,newIntent(LancherDemoActivity.this,LancherDemoActivity.class).setAction(<spanstyle="color:#FF0000;">"com.android.action.test"</span>));
-
-
-
sendBroadcast(shortcut);
-
}
-
});
-
-
-
-
-
button2.setOnClickListener(newOnClickListener(){
-
publicvoidonClick(Viewv){
-
deleteShortCurt2DeskTop();
-
}
-
-
privatevoiddeleteShortCurt2DeskTop(){
-
Intentshortcut=newIntent("com.android.launcher.action.UNINSTALL_SHORTCUT");
-
-
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"TonyAutoShortCut");
-
-
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,newIntent(LancherDemoActivity.this,LancherDemoActivity.class).setAction(<spanstyle="color:#FF0000;">"com.android.action.test"</span>));
-
sendBroadcast(shortcut);
-
}
-
});
-
-
-
}
-
}
注意事项: 在设置 EXTRA_SHORTCUT_INTENT时,添加和删除快捷方式的这个INTENT对象的ACTION属性必须设置为相同内容,才能声明删除和创建的快捷方式是一个,进行绑定,
否则删除无法生效
分享到:
相关推荐
继上一个版本绿色+汉化+免注册+特别版>之后再次放出一个最新版,上一个版本的地址是http://download.csdn.net/download/sibang/4636245 上一个版本放出之后收到了大家的好评,曾一度进入了CSDN的下载排行榜,这次放出...
CSDN: http://blog.csdn.net/rain_butterfly 中文版文档 AndroidTVLauncher This is a tv launcher, include a leanback launcher(minSdkVersion 17) and a normal launcher(minSdkVersion 15). Notice ...
解决双击 jar 和 class文件不能直接在windows命令提示符下运行的问题,不用手动修改注册表和环境变量,把文件的打开方式设为本程序即可
下载的资源按照我文章中所描述的内容https://blog.csdn.net/weixue9/article/details/107814561针对原生的launcher3代码做了大部分修改,横竖屏都有适配,我自己使用时直接删除了hotseat相关的部分,不过下载资源中...
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tigongzhe" android:versionCode="1" android:versionName="1.0" > android:minSdkVersion="8" android:...
Changing the bar color won't take full effect until all UserscriptActivity instances are destroyed (i.e. rotating the screen or restarting the app) Fixed in 4.1.5 Creating a new thread, then going to ...
NULL 博文链接:https://dai-lm.iteye.com/blog/1462418
在Eclipse中编译运行Android4.3应用源码:Launcher2源码包。详细请参阅在Eclipse中编译运行Android4.3应用源码——Launcher2和Gallery2 http://blog.csdn.net/klpchan/article/details/11843295
android:icon="@drawable/ic_launcher" android:label="@string/app_name" > 这里需要添加key,创建应用后,会有这个key android:name="com.baidu.lbsapi.API_KEY" android:value="6t2yuIFylnRG7ECj1xHYuelY...
这个是android Launcher2.2 源码,我最近在学习,有人想跟我交流就到我的博客:http://blog.csdn.net/gqdy365
Aj_01 来自:http://blog.csdn.net/Android_Tutor/archive/2010/04/14/5486804.aspx 测试:Android Launcher抽屉类SlidingDrawer的使用!
原文:http://blog.csdn.net/u012964281/article/details/41143169
Android中实现Launcher功能之添加快捷方式
资源分类:Python库 所属语言:Python 资源全名:otel-fso-launcher-0.1.4.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:minecraft_launcher_core-0.3.2-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
配置Launcher需要的文件。 包括:android.support.v13.dreams包中的BasicDream.java文件; 三个jar包:android-common_intermediates;...http://blog.csdn.net/singleton1900/article/details/8806978
资源分类:Python库 所属语言:Python 资源全名:hydra_joblib_launcher-1.1.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:dead_hosts_launcher-1.4.1-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:conan_app_launcher-0.7.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:aws_emr_launcher-0.1.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059