Android面试题随笔1

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     }

 

转载于:https://www.cnblogs.com/rookieFly-tdiitd/p/5143645.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值