基本信息
源码名称:android 模块化开发示例源码下载
源码大小:4.50M
文件格式:.zip
开发语言:Java
更新时间:2014-03-21
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

package com.example.myapkplughelloworld;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import org.apkplug.app.PropertyInstance;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;

public class MyProperty implements PropertyInstance{
	private   Context context;
	private static MyProperty _instance=null;
	public MyProperty(Context context){
		this.context=context;
	}
	synchronized public static MyProperty getInstance(Context context){
    if(_instance==null){
    _instance=new MyProperty(context);
    }
    return _instance;
    } 

	public String getProperty(String key) {
		// TODO Auto-generated method stub
		SharedPreferences sharedata = PreferenceManager.getDefaultSharedPreferences(this.context);
		String data = sharedata.getString(key, null);
		return data;
	}
	public void setProperty(String key, String v) {
		// TODO Auto-generated method stub
		SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this.context); 
		Editor edit = settings.edit();
		edit.putString(key, v);
		edit.commit();
	}
	public String[] AutoInstall() {
		// TODO Auto-generated method stub
		return null;
	}
	public String[] AutoStart() {
		File f0=null,f1=null;
		try {
			InputStream in=context.getAssets().open("myBundle.apk");
			f0=new File(context.getFilesDir(),"myBundle.apk");
			if(!f0.exists())
			 copy(in, f0);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			InputStream in=context.getAssets().open("myBundle1.apk");
			f1=new File(context.getFilesDir(),"myBundle1.apk");
			if(!f1.exists())
			 copy(in, f1);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	return new String[]{"file:" f0.getAbsolutePath(),"file:" f1.getAbsolutePath()};
	}
	private void copy(InputStream is, File outputFile)
	        throws IOException
	    {
	        OutputStream os = null;

	        try
	        {
	            os = new BufferedOutputStream(
	                new FileOutputStream(outputFile),4096);
	            byte[] b = new byte[4096];
	            int len = 0;
	            while ((len = is.read(b)) != -1)
	                os.write(b, 0, len);
	        }
	        finally
	        {
	            if (is != null) is.close();
	            if (os != null) os.close();
	        }
	    }
	
}