File(fd)); 53 shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 54 shareIntent.putExtra(Intent.EXTRA_TEXT, body);
Java 代码
55
mime = “img/jpg”;
56 shareIntent.setDataAndType(Uri.fromFile(fd), mime); 57 shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fd)); 58 shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 59 shareIntent.putExtra(Intent.EXTRA_TEXT, body);
7:
注册一个 BroadcastReceiver
Java 代码
60 registerReceiver(mMasterResetReciever, new IntentFilter(”oms.action.MASTERRESET”)); 61 private BroadcastReceiver mMasterResetReciever = new BroadcastReceiver() { 62 public void onReceive(Context context, Intent intent){
63 64 65 66 67 68
Java 代码
String action = intent.getAction(); if(”oms.action.MASTERRESET”.equals(action)){ RecoverDefaultConfig(); } } };
69 registerReceiver(mMasterResetReciever, new IntentFilter(”oms.action.MASTERRESET”)); 70 private BroadcastReceiver mMasterResetReciever = new BroadcastReceiver() { 71 72 73 74 75 76 77 }; } } public void onReceive(Context context, Intent intent){ String action = intent.getAction(); if(”oms.action.MASTERRESET”.equals(action)){ RecoverDefaultConfig();
8:定义 ContentObserver,监听某个数据表
Java 代码
78
79 80 private ContentObserver mDownloadsObserver = new DownloadsChangeObserver(Downloads.CONTENT_URI); 81 private class DownloadsChangeObserver extends ContentObserver { 82 83 84 85 86 87 88
Java 代码
public DownloadsChangeObserver(Uri uri) { super(new Handler()); } @Override public void onChange(boolean selfChange) {} }
89 private ContentObserver mDownloadsObserver = new DownloadsChangeObserver(Downloads.CONTENT_URI); 90 private class DownloadsChangeObserver extends ContentObserver { 91 92 93 94 95 96 97 } @Override public void onChange(boolean selfChange) {} } public DownloadsChangeObserver(Uri uri) { super(new Handler());
9:获得 手机 UA
Java 代码
98 public String getUserAgent() 99 100 { String user_agent =
ProductProperties.get(ProductProperties.USER_AGENT_KEY, null); 101 102
Java 代码
return user_agent; }
103 public String getUserAgent() 104 105 { String user_agent =
ProductProperties.get(ProductProperties.USER_AGENT_KEY, null); 106 107 } return user_agent;
10:清空手机上 Cookie
Java 代码
108 CookieSyncManager.createInstance(getApplicationContext()); 109 CookieManager.getInstance().removeAllCookie();
Java 代码
110 CookieSyncManager.createInstance(getApplicationContext()); 111 CookieManager.getInstance().removeAllCookie();
11:建立 GPRS 连接
Java 代码
112 //Dial the GPRS link. 113 private boolean openDataConnection() { 114 115 116 117 “cmwap”); 11
8 119 120 121 }
Java 代码
// Set up data connection. DataConnection conn = DataConnection.getInstance(); if (connectMode == 0) { ret = conn.openConnection(mContext, “cmwap”, “cmwap”,
} else { ret = conn.openConnection(mContext, “c