zoukankan      html  css  js  c++  java
  • [Android实例] 高速静默更新,低流量耗费,让APP活跃起来!

    大家好。我是csdn的新人,给大家带来一个做了一个星期的SDK,能够实现将Android APP碎片化管理。自由更新,实时更新,低流量耗费的更新~~


    Zag Whim Renewal


    A system for quicker updating on Android


    首先你要有一个Bmob移动后端云服务平台的账号

    接下来,进入APP的数据浏览,在APP内建ZwrFile表。加入File类型的file列。加入String类型的name列

    在Eclipse或者Android studio新建两个项目,称为Basic端和Expand端,分别导入相应的SDK

    Basic端的Activity继承自ZwrActivity,实现InitListener接口,在onCreate方法内。先super。再Bmob.initialize(getApplicationContext(), appid),最后setZwrView("类名", this, true, false);

    appid取自bmob后台。在“应用信息”里查看
    “类名”为Expand端相应的类名,如“com.test.bmob.FirstView”
    编译执行Basic端到手机

    放一个layout.xml文件到ZwrFile表的file,name能够随便取,比方“main.xml”

    Expand端删除全部代码。新建一个类。类名为上文所提到的(“com.test.bmob.FirstView”)。继承自ZwrExpandView
    将实现的抽象方法的LayoutName返回layout文件在ZwrFile相应的name。如上文的“main.xml”
    在init函数内写初始化方法

    编译Expand端,将编译出来的bin目录下的classes.dex上传到ZwrFile,name改为类名(“com.test.bmob.FirstView”


    启动Basic端,就可以看到更新效果
    以后须要更新逻辑代码。仅仅需更新Activity相应的dex文件就可以,须要更新布局,就更新相应的xml文件

     

     

    部分代码演示样例:

    Basic端:

     

    import android.os.Bundle;
    import android.widget.Button;
    import cn.bmob.v3.Bmob;
    
    import com.zwr.ZwrActivity;
    import com.zwr.ZwrListener.InitListener;
    
    public class MainActivity extends ZwrActivity implements InitListener {
    
    	private Button bt;
    
    	private final String appid = "";
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    
    		Bmob.initialize(getApplicationContext(),appid);
    		setZwrView("com.testzwr.ThirdView", this, true);
    	}
    	
    	@Override
    	public void succeed() {
    		init();
    	}
    
    	@Override
    	public void fail(String why) {
    		toast(why);
    	}
    
    	@Override
    	public void lastView() {
    		init();
    	}
    	
    	private final void init() {
    		bt = getView("zwrButton");
    		if (bt != null) {
    			bt.setText("hahhaa");
    		}
    	}
    }
    


     

     Extand端:

    package com.testzwr;
     
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
    
    import com.zwr.ZwrBasic.ZwrExpandView;
    import com.zwr.ZwrTool;
    
    public class ThirdView extends ZwrExpandView implements OnClickListener {
    
    	private Button bt;
    	private EditText et;
    	private TextView tv;
    	private Button bt_toast, bt_dialog, bt_change;
    
    	public ThirdView(Activity activity) {
    		super(activity);
    	}
    
    	@Override
    	public String LayoutName() {
    		return "third_layout.xml";
    	}
    
    	@Override
    	public void init() {
    		try {
    			et = getView("msg_et");
    			bt = getView("msg_send");
    			tv = getView("msg_show");
    
    			bt_toast = getView("toast");
    			bt_dialog = getView("dialog");
    			bt_change = getView("change");
    		} catch (NullPointerException e) {
    			return;
    		}
    
    		bt.setOnClickListener(new OnClickListener() {
    
    			@Override
    			public void onClick(View v) {
    				tv.append(et.getText().toString() + "
    ");
    				et.setText("");
    			}
    		});
    
    		bt_toast.setOnClickListener(this);
    		bt_dialog.setOnClickListener(this);
    		bt_change.setOnClickListener(this);
    
    	}
    
    	private AlertDialog dialog;
    
    	@Override
    	public void onClick(View v) {
    		int i = v.getId();
    		if (i == bt_toast.getId()) {
    			Toast.makeText(getContext(), "hahaha", 1).show();
    		} else if (i == bt_dialog.getId()) {
    			if (dialog == null)
    				dialog = new AlertDialog.Builder(getContext())
    						.setMessage("Hi~~").setTitle("恭喜你!").create();
    			dialog.show();
    		} else if (i == bt_change.getId()) {
    			bt_toast.setText("改变啦~丧失Toast能力,但能跳转到还有一个Activity");
    			bt_dialog.setText("改变了还能弹窗");
    			bt_toast.setOnClickListener(new OnClickListener() {
    
    				@Override
    				public void onClick(View v) {
    					try {
    						ZwrTool.startActivity("com.test.sdkbuilder.SecondActivity");
    					} catch (ClassNotFoundException e) {
    						Toast.makeText(getContext(), "no this class", 1).show();
    						e.printStackTrace();
    					}
    				}
    			});
    			v.setVisibility(View.GONE);
    		}
    	}
    
    }
    



     

     layout文件:(third_layout.xml)

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingBottom="10dip"
        android:paddingTop="10dip" >
    
        <Button
            android:id="@+id/toast"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="点击我就会弹吐司" />
    
        <Button
            android:id="@+id/dialog"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="点击我就会弹Dialog" />
    
        <Button
            android:id="@+id/change"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="点击我会改变上面两个button" />
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
    
            <LinearLayout
                android:id="@+id/msg_ll"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:orientation="horizontal" >
    
                <EditText
                    android:id="@+id/msg_et"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="4"
                    android:hint="输入信息" />
    
                <Button
                    android:id="@+id/msg_send"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="发送" />
            </LinearLayout>
     
            <TextView
                android:id="@+id/msg_show"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="hahaha"
                android:layout_above="@+id/msg_ll"
                android:layout_alignParentTop="true" />
        </RelativeLayout>
    
    </LinearLayout>




    详细说明文档及SDK下载。请下载~~

     

    下载地址:

    http://download.csdn.net/detail/u013589048/8517631


  • 相关阅读:
    C# 根据主窗体的位置弹窗信息窗体一直保持在主窗体中间
    c# winForm父子窗口 通过委托进行信息传递
    使用devexpress插件 消除运行时弹窗
    C# 获取当前时间戳
    WinForm实现Loading等待界面
    转载 C#设置控件 Enabled 为 false 时背景色不改变
    DEV gridView中加入加载条显示进度,必须为圆角型
    winfrom 圆角化
    列表元素的反转、排序——python
    使用for循环和while循环打印九九乘法表——python
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/6958580.html
Copyright © 2011-2022 走看看