Browse Source

【提交内容】:退出应用,清除内存

wangyj18 9 years ago
parent
commit
cfd6358caf
1 changed files with 31 additions and 27 deletions
  1. 31 27
      wade-mobile-func/src/com/wade/mobile/func/MobileApp.java

+ 31 - 27
wade-mobile-func/src/com/wade/mobile/func/MobileApp.java

13

13

14
public class MobileApp extends Plugin {
14
public class MobileApp extends Plugin {
15
	private Intent callbackIntent;
15
	private Intent callbackIntent;
16
	
16

17
	public MobileApp(IWadeMobile wademobile) {
17
	public MobileApp(IWadeMobile wademobile) {
18
		super(wademobile);
18
		super(wademobile);
19
	}
19
	}
20

20

21
	public void close(JSONArray param) throws Exception {
21
	public void close(JSONArray param) throws Exception {
22
		boolean showConfirm = false;
22
		boolean showConfirm = false;
23
		if(param.length()==1){
24
			showConfirm = !isNull(param.getString(0))&&Constant.TRUE.equals(param.getString(0));
23
		if (param.length() == 1) {
24
			showConfirm = !isNull(param.getString(0))
25
					&& Constant.TRUE.equals(param.getString(0));
25
		}
26
		}
26
		close(showConfirm);
27
		close(showConfirm);
27
	}
28
	}
28
	
29

29
	/**
30
	/**
30
	 * 退出应用JS调用	
31
	 * 退出应用JS调用
31
	 */
32
	 */
32
	public void close(Boolean showConfirm) {
33
	public void close(Boolean showConfirm) {
33
		// TODO Auto-generated method stub
34
		// TODO Auto-generated method stub
34
		if (this.context instanceof IWadeMobile){
35
			if(showConfirm){
36
				wademobile.getWadeMobileClient().shutdownByConfirm(Messages.CONFIRM_CLOSE);
37
			}else{
38
				if(callbackIntent!=null){
39
					wademobile.getActivity().setResult(0, callbackIntent);
40
				}
41
				wademobile.getActivity().finish();
42
				callbackIntent = null;
35
		if (this.context instanceof IWadeMobile) {
36
			if (showConfirm) {
37
				wademobile.getWadeMobileClient().shutdownByConfirm(
38
						Messages.CONFIRM_CLOSE);
39
			} else {
40
				// if(callbackIntent!=null){
41
				// wademobile.getActivity().setResult(0, callbackIntent);
42
				// }
43
				// wademobile.getActivity().finish();
44
				// callbackIntent = null;
45

46
				wademobile.getWadeMobileClient().exitApp();
43
			}
47
			}
44
		}
48
		}
45
	}
49
	}
46
	
50

47
	public void setResult(JSONArray param) throws Exception {
51
	public void setResult(JSONArray param) throws Exception {
48
		setResult(param.getString(0),param.getString(1));
52
		setResult(param.getString(0), param.getString(1));
49
	}
53
	}
50
	
54

51
	/**
55
	/**
52
	 * 设置返回值	
56
	 * 设置返回值
53
	 */
57
	 */
54
	public void setResult(String key, String value) {
58
	public void setResult(String key, String value) {
55
		// TODO Auto-generated method stub
59
		// TODO Auto-generated method stub
56
		if(callbackIntent==null){
57
			callbackIntent = new Intent(); 
60
		if (callbackIntent == null) {
61
			callbackIntent = new Intent();
58
		}
62
		}
59
		callbackIntent.putExtra(key, value);
63
		callbackIntent.putExtra(key, value);
60
	}
64
	}
61
	
62
	public void logCat(JSONArray param) throws JSONException{
63
		String msg=param.getString(0);
64
		String title=param.getString(1);
65
		if(title==null){
66
			title="LogCat";
65

66
	public void logCat(JSONArray param) throws JSONException {
67
		String msg = param.getString(0);
68
		String title = param.getString(1);
69
		if (title == null) {
70
			title = "LogCat";
67
		}
71
		}
68
		MobileLog.i(title,msg );
72
		MobileLog.i(title, msg);
69
	}
73
	}
70
}
74
}