Android面试题随笔1
2024-08-24 07:30:11
1.如何让一个应用在手机上产生两个或多个图标?
在清单文件中的activity节点下配置如下:【5,7行代码】
<activity
android:name=".MainActivity"
android:label="aaaa" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SplashActivity"
android:label="bbbb" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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.创建应用桌面快捷图标
private void createHomeShortCut() {
boolean shortcut = sp.getBoolean("shortcut", false);
if(shortcut) //判断是否已经创建了桌面快捷图标
return;
Editor editor = sp.edit();
//发送广播的意图, 大吼一声告诉桌面,要创建快捷图标了
Intent intent = new Intent();
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
//快捷方式 要包含3个重要的信息 1,名称 2.图标 3.干什么事情
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "手机小卫士");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
//桌面点击图标时启动并展示相应的activity。
Intent shortcutIntent = new Intent();
shortcutIntent.setAction("android.intent.action.MAIN");
shortcutIntent.addCategory("android.intent.category.LAUNCHER");
shortcutIntent.setClassName(getPackageName(), "com.zhu.mobilesafe.SplashActivity");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
//发送广播意图
sendBroadcast(intent);
//修改应用设置为已创建快捷图标
editor.putBoolean("shortcut", true);
editor.commit();
}
最新文章
- BFC之浅析篇
- jq实现楼层切换效果
- 【NHibernate】配置- sql打印
- [Android] 获取音频输出getOutput
- SGU 106 The Equation 扩展欧几里得应用
- CentOS 7 服务器配置--配置iptables防火墙
- java简单数据类型转化
- protocol_v2.go
- VS2015 与 Git 的简单使用
- 【一】、搭建Hadoop环境----本地、伪分布式
- 求1+2+……+n的和
- 各种SQL查询技巧汇总 (转)
- SQL Server 性能优化详解
- Android -- View流程
- 【Unity笔记】用代码动态修改Animator状态机的状态
- CSS技巧:逐帧动画抖动解决方案
- javaweb 读取properties配置文件参数
- x-code的使用技巧心得
- u-boot 2011.09 使用自己的board 以及config.h
- windows下libcurl与zlib和ssl共同编译