Android 开发之系统应用Launcher详解,简单添加和删除快捷方式及常见问题

1..Launcher是什么?


1.1Launcher是系统启动后加载的第一个应用程序

1.2Launcher是其他应用程序的入口


2.Launcher的构成:


3. 主体四大组件的区别:

ShortCut:应用程序的快捷方式

Appwidget:桌面小部件,图形不规则

LiveFolder:文件夹

ContentProvider的形式展示应用中特定数据的集合

WallPaper:壁纸



预览图如下:



4. 通过按钮添加或者删除应用程序的快捷方式Demo:


Intent.EXTRA_SHORTCUT_INTENT,

布局文件:

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns: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="Install ShortCurt" />

    <Button
        android:id="@+id/BT_UnInstallShortCurt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="UnInstall ShortCurt" />

</LinearLayout>


清单文件Mainifest.xml


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

    <uses-sdk android:minSdkVersion="8" />
    <!-- 该权限为系统自定义权限 -->
	<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />  
	<uses-permission android: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>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
        <activity android:name=".ShortCutActivity">
        
    <!-若希望在长按Menu键,添加快捷方式中出现应用条目,则需要加入以下内容->

<intent-filter ><action android:name="android.intent.action.CREATE_SHORTCUT"/> </intent-filter> </activity> </application></manifest>
 

LancherDemoActivity;


import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class LancherDemoActivity extends Activity {
    private Button button1;
    private Button button2;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button1 = (Button) findViewById(R.id.BT_InstallShortCurt);
        button2 = (Button) findViewById(R.id.BT_UnInstallShortCurt);
        button1.setOnClickListener(new OnClickListener() {
			
public void onClick(View v) {
	addShortCurt2DeskTop();
	}

/**
 * 添加桌面快捷方式
*/
private void addShortCurt2DeskTop() {
        Intent shortcut = new Intent("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, new Intent(LancherDemoActivity.this,LancherDemoActivity.class).setAction("com.android.action.test"));

//发送广播
sendBroadcast(shortcut);
	}
});
        
/**
* 删除桌面快捷方式
*/
button2.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
    deleteShortCurt2DeskTop();  
   }
   
   private void deleteShortCurt2DeskTop() {
   Intent shortcut = new   Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");  
		          
        //快捷方式的名称  
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "TonyAutoShortCut");  
			          
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(LancherDemoActivity.this,LancherDemoActivity.class).setAction("com.android.action.test"));  
			    sendBroadcast(shortcut);
			}
		});
        
        
    }
}


注意事项: 在设置 EXTRA_SHORTCUT_INTENT时,添加和删除快捷方式的这个INTENT对象的ACTION属性必须设置为相同内容,才能声明删除和创建的快捷方式是一个,进行绑定,

否则删除无法生效






  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Android是一个功能强大的移动操作系统,它广泛应用于手机、平板电脑和其他移动设备。在这些Android设备上,launcher或称启动器被用来管理应用程序。它是一个显示在设备主屏幕上的应用程序,使用户可以启动其他应用程序。因此,进行androidlauncher应用开发是很重要的。 Android launcher工具和技术提供了广泛的选择,开发人员可以使用自己选择的编程语言建立自己的launcher。大多数开发人员使用Java和Kotlin作为编程语言。这些应用程序可以通过下载Google Play商店轻松获得。 Android launcher应用程序的核心功能是为用户提供直观的界面来访问其他应用程序,例如联系人、邮件、地图和其他应用程序等。此外,launcher应用程序还具有许多自定义功能和设置,例如对话框、调色板、皮肤、图标和管理器等,这些功能可以提高应用程序的可用性和功能性。 在开发androidlauncher应用程序时,开发人员需要考虑多个方面,例如用户权限、应用程序存储、安全和隐私、容错和可扩展性等。了解这些方面可以帮助开发人员开发一个高效的androidlauncher应用程序。 总之,androidlauncher应用程序提供了一个用于管理和访问其他应用程序的界面。开发人员可以利用该应用程序的自定义功能和设置来为用户提供更好的用户体验。 ### 回答2: Android Launcher应用开发涉及到许多方面的知识,无论是从技术方面还是设计方面,都需要开发者具备一定的专业知识和经验。 在技术方面,开发者需要熟悉Java和Android开发框架,并且需要了解Android的UI组件,并掌握使用各种工具和技术来实现Launcher应用。此外,还需要了解与Launcher应用相关的系统接口、网络通信、存储和安全技术等方面的知识,以便将其与应用程序无缝集成。 在设计方面,开发者需要具备一定的平面设计和人机交互设计的能力,以便开发出符合用户需求、易于操作的Launcher应用程序。开发者需要考虑到用户的使用习惯和体验,并且以此为基础设计应用UI,例如图标和文件夹的设计等,以及提供用户自定义功能和定制主题的支持。 最后,值得注意的是,Android Launcher应用应该遵循Android生态系统的标准,并确保应用程序的兼容性和安全性。因此,开发者需要保持不断学习和更新自己的知识,并且严格遵守Android开发官方文档和开发标准,以开发出高质量、易于使用和安全的应用程序。 ### 回答3: Android Launcher是一款可自定义的android桌面启动器应用程序,它能够覆盖手机自带的桌面启动器,让用户能够更加自由地控制自己的手机界面。那么,如何开发出一款优秀的Android Launcher呢? 首先,我们需要学习Android开发的基础知识,包括Java编程语言、Android SDK、Android Studio开发环境等。接着,我们需要理解Andorid中Launcher的核心知识,如桌面、文件夹、应用程序图标、小部件等等。此外,我们还需要学习Android中UI布局的知识,了解如何创建各种UI元素,并将其组合成一个完整的Launcher界面。 在实现Launcher的功能时,可以考虑加入搜索、分类、快速启动等各种功能,以提高用户的使用体验。同时,还可以设置各种自定义选项,如主题皮肤、桌面布局、图标大小等,让用户能够根据自己的习惯和偏好来调整Launcher。 最后,我们需要注意应用的性能和稳定性,尤其是在较低配置的手机上运行时,应该保证应用程序的快速响应和流畅运行。为达到这一目的,我们需要考虑应用资源的调用和管理、使用合适的UI动画效果等措施,以优化应用程序的性能。 在实现Android Launcher应用开发的过程中,需要运用诸多技术,也需要充分考虑用户的需求和体验,以确保应用程序能够达到优秀的质量和用户体验。同时,开发者应该关注Android系统的升级和更新,及时调整和改进Launcher应用程序,以保持其在竞争激烈的市场中的竞争力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值