知識(shí)
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們?cè)谧非笃湟曈X(jué)表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營(yíng)銷(xiāo)的便利,運(yùn)營(yíng)的高效,讓網(wǎng)站成為營(yíng)銷(xiāo)工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!
Android中應(yīng)用的快捷方式的創(chuàng)建
發(fā)表時(shí)間:2020-10-19
發(fā)布人:葵宇科技
瀏覽次數(shù):39
(一)應(yīng)用發(fā)送廣播來(lái)進(jìn)行創(chuàng)建快捷方法:該demo例子實(shí)現(xiàn)的功能是:在界面有一個(gè)按鈕,點(diǎn)擊按鈕生成一個(gè)快捷方法,然后點(diǎn)擊快捷方法進(jìn)入撥打德律風(fēng)的頁(yè)面;
生成步調(diào)如下:
1:如下權(quán)限: <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
2:在Activity中new一個(gè)Intent參加Action:
_Intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
3:其他核心代碼如下:
Intent _ReturnIntent = new Intent();
// 設(shè)置創(chuàng)建快捷方法的過(guò)濾器action
_ReturnIntent
.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
// 設(shè)置生成的快捷方法的名字
_ReturnIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
"Broad ShortCut");
// 設(shè)置生成的快捷方法的擱筆
_ReturnIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(
LauncherActivity.this, R.drawable.ic_launcher));
Intent _Intent = new Intent(Intent.ACTION_CALL);
_Intent.setData(Uri.parse("tel://5556"));
_ReturnIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, _Intent);
// 發(fā)送廣播生成快捷方法
sendBroadcast(_ReturnIntent);
LauncherActivity.this.finish();
}
當(dāng)然膳綾擎要參加撥打德律風(fēng)的權(quán)限:
<uses-permission android:name="android.permission.CALL_PHONE" />
如不雅我們想要卸載快捷方法,須要在構(gòu)造文件中參加權(quán)限
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
然后intent中傳入 com.android.launcher.permission.UNINSTALL_SHORTCUT
(二):應(yīng)用一個(gè)Activity,然后在Home界面點(diǎn)擊Menu->添加->選擇快捷方法->選擇創(chuàng)建的應(yīng)用法度榜樣的快捷方法,看如下的效不雅:
創(chuàng)建步調(diào)如下:
①:在Androidmanifset.xml文件中注冊(cè)Activity
②:在IntentFiler標(biāo)簽下面參加<action/>
看下Activity中的核心代碼:
public class ShortCutSample extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
if (getIntent().getAction().equals(
"android.intent.action.CREATE_SHORTCUT")) {
Intent _ReturnIntent = new Intent();
//設(shè)置快捷方法的名字
_ReturnIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
"jiangqq ShortCut");
//設(shè)置快捷方法的擱筆
_ReturnIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this,
R.drawable.ic_launcher));
Intent _Intent=new Intent(Intent.ACTION_CALL);
_Intent.setData(Uri.parse("tel://10086"));
//當(dāng)據(jù)方法創(chuàng)建完成之后,點(diǎn)擊擱筆跳轉(zhuǎn)到撥打撥打德律風(fēng)的頁(yè)面
_ReturnIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(
this, LauncherActivity.class));
//設(shè)置返回值,一般是OK,
setResult(RESULT_OK, _ReturnIntent);
finish();
}
}
相關(guān)案例查看更多
相關(guān)閱讀
- 云南網(wǎng)站建設(shè)百度
- web學(xué)習(xí)路線(xiàn)
- 開(kāi)發(fā)制作小程序
- 云南做網(wǎng)站
- 昆明軟件公司
- 汽車(chē)報(bào)廢回收
- 花農(nóng)小程序
- 云南網(wǎng)站開(kāi)發(fā)哪家好
- 云南網(wǎng)站建設(shè)費(fèi)用
- 江蘇小程序開(kāi)發(fā)
- 云南旅游網(wǎng)站建設(shè)
- 云南網(wǎng)站建設(shè)選
- 百度快速排名
- 網(wǎng)站建設(shè)首選
- 怎么做網(wǎng)站
- 大理網(wǎng)站建設(shè)公司
- 汽車(chē)報(bào)廢回收管理系統(tǒng)
- 云南小程序代建
- 云南電商網(wǎng)站建設(shè)
- 昆明網(wǎng)站制作
- 云南省城鄉(xiāng)建設(shè)廳網(wǎng)站
- 小程序開(kāi)發(fā)課程
- 昆明小程序開(kāi)發(fā)
- 云南網(wǎng)站建設(shè)案例
- 云南花農(nóng)小程序
- 云南網(wǎng)站開(kāi)發(fā)
- 小程序密鑰
- 分銷(xiāo)系統(tǒng)
- 云南網(wǎng)站建設(shè)公司
- 云南網(wǎng)站建設(shè)招商