android 代码实现(预装)安装apk

工作中学习到的,记下来,以免忘记啊



要在界面安装相应的APK的快捷键首先得先预装相应的APK才行,其次在相应的xml文件中定义xy值制定其位置,这样就达到你的目的了、、、、、

一、在路径下packages/apps/Launcher2/res/xml/ default_workspace.xml 文件中有appwidget和favorite,你可以按需选择,填入APK的包(源码应该看的懂吧,照葫芦画瓢咯),这一步是写好你要预装的APK的包,然后定义好其显示在Luacher中的位置。


二、预装APK咯

a、把要预装的APK复制到路径out/target/product/crane-xh7/system/app下


b、把要预装的APK复制到路径 device/softwinner/系统/apk下面,然后写一个Android.mk文件,文件内容如下,你只需要把写apk的地方改成你要预装的apk的名字即可。

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := you.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/3rdapks
LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

include $(CLEAR_VARS)

LOCAL_MODULE := you.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/3rdapks
LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

include $(CLEAR_VARS)

LOCAL_MODULE := you.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/3rdapks
LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

include $(CLEAR_VARS)

LOCAL_MODULE := you.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/3rdapks
LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

include $(CLEAR_VARS)

LOCAL_MODULE := you.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/3rdapks
LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)



(随你APK的个数来定义文件)


c、在路径device/softwinner/系统/系统.mk文件中PRODUCT_PACKAGES += \下面写下要预装的APK,如下


PRODUCT_PACKAGES += \
   you.apk \
   you.apk \
    you.apk \
    Sogou.apk 



然后编译,APK预装完成
  

你可能感兴趣的:(android 代码实现(预装)安装apk)