android 创建桌面快捷方式指向 PDF 文件
LauncherCutTestActivity.java 代码:
package android.hyemiletoe;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class LauncherCutTestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent shortcutIntent = new
Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.
title));
shortcutIntent.putExtra("duplicate", false);
Intent intent3=new Intent();
intent3.setAction("android.intent.action.VIEW");
intent3.setDataAndType(Uri.parse(getString(R.string.data)),getString(
R.string.type));//关联 PDF 文档或其它 MimeType
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent3);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.Sh
ortcutIconResource.fromContext(this,R.drawable.icon));
sendBroadcast(shortcutIntent);
finish();
}
}
AndroidManifest.xml 文件:
String.xml 文件:
LauncherCutTest
说明书
file:///sdcard/T704_cn.pdf
application/pdf
另外一种方法添加 android 设备或模拟机 桌面快捷方式的方法:
修改数据库文件,下载 SQLiteManager,找到 Tables ,右击 favorites,点 query
查询,在查询出来的表格
中添加一条记录就可以了
从设备或模拟机上下载 launcher.db
echo off
adb shell ls /data/data/com.android.launcher/databases >0.txt
adb pull /data/data/com.android.launcher/databases/launcher.db
pause
修改好后再上传:
@echo off
echo 正在上传 build.prop 到机器……
adb remount
adb push ./launcher.db
/data/data/com.android.launcher/databases/launcher.db