1.如何让一个应用在手机上产生两个或多个图标?
在清单文件中的activity节点下配置如下:【5,7行代码】
1 <activity 2 android:name=".MainActivity" 3 android:label="aaaa" > 4 <intent-filter> 5 <action android:name="android.intent.action.MAIN" /> 6 7 <category android:name="android.intent.category.LAUNCHER" /> 8 </intent-filter> 9 </activity>
1 <activity 2 android:name=".SplashActivity" 3 android:label="bbbb" > 4 <intent-filter> 5 <action android:name="android.intent.action.MAIN" /> 6 7 <category android:name="android.intent.category.LAUNCHER" /> 8 </intent-filter> 9 </activity>
该应用即会在手机出现两个相同的图标,均可打开此应用程序,而且应用名称可以不一样。
2. 请介绍下Android中常用的五种布局。
介绍完5种布局【及使用方法或特色】后,要突出补充一些各自的特性才能出彩。
FrameLayout主要用在游戏和视频应用上。TableLayout主要应用在证券和金融上。AbsoluteLayout主要应用在机顶盒【不用考虑屏幕适配】的应用上。
常用的是RelativeLayout和LinearLayout。并且,首先考虑的是RelativeLayout,因为它的效率要比LinearLayout高,原因是一般情况下RelativeLayout的层级【hierarchyviewer.bat】比LinearLayout低。
3.Android测试步骤:
清单文件总声明: <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.zhu.mobilesafe" />
application节点下声明: <uses-library android:name="android.test.runner" />
测试类继承 AndroidTestCase extends AndroidTestCase
4.创建应用桌面快捷图标
1 private void createHomeShortCut() { 2 boolean shortcut = sp.getBoolean("shortcut", false); 3 if(shortcut) //判断是否已经创建了桌面快捷图标 4 return; 5 Editor editor = sp.edit(); 6 //发送广播的意图, 大吼一声告诉桌面,要创建快捷图标了 7 Intent intent = new Intent(); 8 intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); 9 //快捷方式 要包含3个重要的信息 1,名称 2.图标 3.干什么事情 10 intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "手机小卫士"); 11 intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); 12 //桌面点击图标时启动并展示相应的activity。 13 Intent shortcutIntent = new Intent(); 14 shortcutIntent.setAction("android.intent.action.MAIN"); 15 shortcutIntent.addCategory("android.intent.category.LAUNCHER"); 16 shortcutIntent.setClassName(getPackageName(), "com.zhu.mobilesafe.SplashActivity"); 17 intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); 18 //发送广播意图 19 sendBroadcast(intent); 20 //修改应用设置为已创建快捷图标 21 editor.putBoolean("shortcut", true); 22 editor.commit(); 23 }