├── .gitignore ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── libammsdk.jar │ └── wechat-sdk-android-with-mta-1.0.2.jar └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── net │ │ └── sourceforge │ │ └── simcpux │ │ ├── AddFavoriteToWXActivity.java │ │ ├── AppRegister.java │ │ ├── Constants.java │ │ ├── GetFromWXActivity.java │ │ ├── MD5.java │ │ ├── PayActivity.java │ │ ├── SendToWXActivity.java │ │ ├── ShowFromWXActivity.java │ │ ├── Util.java │ │ ├── uikit │ │ ├── CameraUtil.java │ │ └── MMAlert.java │ │ └── wxapi │ │ ├── WXEntryActivity.java │ │ └── WXPayEntryActivity.java │ └── res │ ├── anim │ └── push_up_in.xml │ ├── color │ ├── mm_actbtn_text.xml │ ├── mm_btn_text.xml │ ├── mm_choice_text_color.xml │ ├── mm_hyper_text.xml │ ├── mm_list_textcolor_one.xml │ ├── mm_list_textcolor_time.xml │ ├── mm_list_textcolor_two.xml │ ├── mm_pref_summary.xml │ ├── mm_pref_title.xml │ ├── mm_style_one_btn_text.xml │ ├── mm_style_two_btn_text.xml │ └── mm_title_btn_text.xml │ ├── drawable-hdpi │ ├── btn_check_off_disable.png │ ├── btn_check_off_normal.png │ ├── btn_check_on_disable.png │ ├── btn_check_on_normal.png │ ├── btn_style_alert_dialog_background.9.png │ ├── btn_style_alert_dialog_button_normal.9.png │ ├── btn_style_alert_dialog_button_pressed.9.png │ ├── btn_style_alert_dialog_cancel_normal.9.png │ ├── btn_style_alert_dialog_special_normal.9.png │ ├── btn_style_alert_dialog_special_pressed.9.png │ ├── btn_style_one_disabled.9.png │ ├── btn_style_one_focused.9.png │ ├── btn_style_one_normal.9.png │ ├── btn_style_one_pressed.9.png │ ├── ic_dialog_alert.png │ ├── ic_dialog_long_click.png │ ├── ic_preference_first_normal.9.png │ ├── ic_preference_first_pressed.9.png │ ├── ic_preference_last_normal.9.png │ ├── ic_preference_last_pressed.9.png │ ├── ic_preference_normal.9.png │ ├── ic_preference_one_normal.9.png │ ├── ic_preference_one_pressed.9.png │ ├── ic_preference_pressed.9.png │ ├── ic_preference_single_normal.9.png │ ├── ic_preference_single_pressed.9.png │ ├── ic_preference_top_normal.9.png │ ├── ic_preference_top_pressed.9.png │ ├── mm_checkbox_mini_checked.9.png │ ├── mm_checkbox_mini_normal.9.png │ ├── mm_edit_focused.9.png │ ├── mm_edit_normal.9.png │ ├── mm_listitem_disable.9.png │ ├── mm_listitem_normal.9.png │ ├── mm_listitem_pressed.9.png │ ├── mm_submenu_normal.png │ ├── mm_submenu_pressed.png │ ├── mm_title_act_btn_disable.9.png │ ├── mm_title_act_btn_focused.9.png │ ├── mm_title_act_btn_normal.9.png │ ├── mm_title_act_btn_pressed.9.png │ ├── mm_title_back_focused.9.png │ ├── mm_title_back_normal.9.png │ ├── mm_title_back_pressed.9.png │ ├── mm_title_bg.9.png │ ├── mm_title_btn_focused.9.png │ ├── mm_title_btn_normal.9.png │ ├── mm_title_btn_pressed.9.png │ ├── mm_trans.png │ ├── send_img.jpg │ ├── send_music_thumb.png │ └── send_music_thumb_backup.png │ ├── drawable-ldpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable │ ├── btn_style_alert_dialog_button.xml │ ├── btn_style_alert_dialog_cancel.xml │ ├── btn_style_alert_dialog_special.xml │ ├── btn_style_one.xml │ ├── list_selector_background.xml │ ├── mm_checkbox_btn.xml │ ├── mm_checkbox_mini.xml │ ├── mm_edit.xml │ ├── mm_submenu.xml │ ├── mm_title_btn_back.xml │ ├── mm_title_btn_right.xml │ ├── preference_first_item.xml │ ├── preference_item.xml │ ├── preference_last_item.xml │ └── preference_one_item.xml │ ├── layout │ ├── add_fav_to_wx.xml │ ├── alert_dialog_menu_layout.xml │ ├── alert_dialog_menu_list_layout.xml │ ├── alert_dialog_menu_list_layout_cancel.xml │ ├── alert_dialog_menu_list_layout_special.xml │ ├── alert_dialog_menu_list_layout_title.xml │ ├── entry.xml │ ├── get_from_wx.xml │ ├── image_button.xml │ ├── mm_activity.xml │ ├── mm_example_ui.xml │ ├── mm_preference.xml │ ├── mm_preference_catalog.xml │ ├── mm_preference_checkbox.xml │ ├── mm_preference_child.xml │ ├── mm_preference_content_choice.xml │ ├── mm_preference_content_domainmail.xml │ ├── mm_preference_content_domainmaillist.xml │ ├── mm_preference_content_keyvalue.xml │ ├── mm_preference_dialog_edittext.xml │ ├── mm_preference_image.xml │ ├── mm_preference_info.xml │ ├── mm_preference_list_content.xml │ ├── mm_preference_null.xml │ ├── mm_preference_screen.xml │ ├── mm_preference_self_vuser.xml │ ├── mm_preference_submenu.xml │ ├── mm_preference_widget_empty.xml │ ├── mm_title.xml │ ├── pay.xml │ ├── pay_result.xml │ ├── security_image.xml │ ├── send_to_wx.xml │ ├── sendrequest_dialog.xml │ ├── show_from_wx.xml │ └── webalert.xml │ └── values │ ├── color.xml │ ├── dimens.xml │ ├── strings.xml │ ├── styles.xml │ └── themes.xml ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── import-summary.txt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | /captures 4 | .externalNativeBuild 5 | 6 | ### Android ### 7 | # Built application files 8 | *.apk 9 | *.ap_ 10 | *.iml 11 | *.swp 12 | *.swo 13 | 14 | # Files for the Dalvik VM 15 | *.dex 16 | 17 | # Java class files 18 | *.class 19 | 20 | # Generated files 21 | bin/ 22 | gen/ 23 | 24 | # Gradle files 25 | .gradle/ 26 | /build 27 | app/release 28 | /output-libs 29 | 30 | # Fastlane 31 | fastlane/report.xml 32 | 33 | # Local configuration file (sdk path, etc) 34 | /local.properties 35 | 36 | # Proguard folder generated by Eclipse 37 | proguard/ 38 | 39 | # Log Files 40 | *.log 41 | 42 | # Android Studio Navigation editor temp files 43 | .navigation/ 44 | 45 | ### Android Patch ### 46 | gen-external-apklibs 47 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "28.0.3" 6 | useLibrary 'org.apache.http.legacy' 7 | 8 | defaultConfig { 9 | applicationId "net.sourceforge.simcpux" 10 | minSdkVersion 19 11 | targetSdkVersion 25 12 | } 13 | 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | // implementation files('libs/libammsdk.jar') 24 | // implementation files('libs/wechat-sdk-android-with-mta-1.0.2.jar') 25 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+' 26 | } 27 | -------------------------------------------------------------------------------- /app/libs/libammsdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/libs/libammsdk.jar -------------------------------------------------------------------------------- /app/libs/wechat-sdk-android-with-mta-1.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/libs/wechat-sdk-android-with-mta-1.0.2.jar -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 39 | 43 | 44 | 48 | 49 | 53 | 54 | 58 | 59 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/AppRegister.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | import com.tencent.mm.opensdk.openapi.IWXAPI; 8 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 9 | 10 | public class AppRegister extends BroadcastReceiver { 11 | 12 | @Override 13 | public void onReceive(Context context, Intent intent) { 14 | final IWXAPI msgApi = WXAPIFactory.createWXAPI(context, null); 15 | 16 | // 将该app注册到微信 17 | msgApi.registerApp(Constants.APP_ID); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/Constants.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | public class Constants { 4 | // APP_ID 替换为你的应用从官方网站申请到的合法appId 5 | public static final String APP_ID = "wxd930ea5d5a258f4f"; 6 | 7 | public static class ShowMsgActivity { 8 | public static final String STitle = "showmsg_title"; 9 | public static final String SMessage = "showmsg_message"; 10 | public static final String BAThumbData = "showmsg_thumb_data"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/GetFromWXActivity.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | import android.app.Activity; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.view.View; 10 | import android.widget.EditText; 11 | import android.widget.LinearLayout; 12 | 13 | import com.tencent.mm.opensdk.modelmsg.GetMessageFromWX; 14 | import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject; 15 | import com.tencent.mm.opensdk.modelmsg.WXImageObject; 16 | import com.tencent.mm.opensdk.modelmsg.WXMediaMessage; 17 | import com.tencent.mm.opensdk.modelmsg.WXMusicObject; 18 | import com.tencent.mm.opensdk.modelmsg.WXTextObject; 19 | import com.tencent.mm.opensdk.modelmsg.WXVideoObject; 20 | import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; 21 | import com.tencent.mm.opensdk.openapi.IWXAPI; 22 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 23 | 24 | import net.sourceforge.simcpux.uikit.CameraUtil; 25 | import net.sourceforge.simcpux.uikit.MMAlert; 26 | 27 | public class GetFromWXActivity extends Activity { 28 | 29 | private static final int THUMB_SIZE = 150; 30 | 31 | private IWXAPI api; 32 | private Bundle bundle; 33 | 34 | @Override 35 | public void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | 38 | // acquire wxapi 39 | api = WXAPIFactory.createWXAPI(this, Constants.APP_ID); 40 | bundle = getIntent().getExtras(); 41 | 42 | setContentView(R.layout.get_from_wx); 43 | initView(); 44 | } 45 | 46 | @Override 47 | public void onNewIntent(Intent intent) { 48 | super.onNewIntent(intent); 49 | bundle = intent.getExtras(); 50 | } 51 | 52 | private void initView() { 53 | 54 | findViewById(R.id.get_text).setOnClickListener(new View.OnClickListener() { 55 | 56 | @Override 57 | public void onClick(View v) { 58 | final EditText editor = new EditText(GetFromWXActivity.this); 59 | editor.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); 60 | editor.setText(R.string.share_text_default); 61 | MMAlert.showAlert(GetFromWXActivity.this, "share text", editor, getString(R.string.app_share), getString(R.string.app_cancel), new DialogInterface.OnClickListener() { 62 | 63 | @Override 64 | public void onClick(DialogInterface dialog, int which) { 65 | String text = editor.getText().toString(); 66 | if (text == null || text.length() == 0) { 67 | return; 68 | } 69 | 70 | // 初始化一个WXTextObject对象 71 | WXTextObject textObj = new WXTextObject(); 72 | textObj.text = text; 73 | 74 | // 用WXTextObject对象初始化一个WXMediaMessage对象 75 | WXMediaMessage msg = new WXMediaMessage(textObj); 76 | msg.description = text; 77 | 78 | // 构造一个Resp 79 | GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp(); 80 | // 将req的transaction设置到resp对象中,其中bundle为微信传递过来的intent所带的内容,通过getExtras方法获取 81 | resp.transaction = getTransaction(); 82 | resp.message = msg; 83 | 84 | // 调用api接口响应数据到微信 85 | api.sendResp(resp); 86 | finish(); 87 | } 88 | }, null); 89 | } 90 | }); 91 | 92 | findViewById(R.id.get_img).setOnClickListener(new View.OnClickListener() { 93 | 94 | @Override 95 | public void onClick(View v) { 96 | // respond with image message 97 | Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.send_img); 98 | WXImageObject imgObj = new WXImageObject(bmp); 99 | 100 | WXMediaMessage msg = new WXMediaMessage(); 101 | msg.mediaObject = imgObj; 102 | 103 | // 设置消息的缩略图 104 | Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true); 105 | bmp.recycle(); 106 | msg.thumbData = Util.bmpToByteArray(thumbBmp, true); 107 | 108 | GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp(); 109 | resp.transaction = getTransaction(); 110 | resp.message = msg; 111 | 112 | api.sendResp(resp); 113 | finish(); 114 | } 115 | }); 116 | 117 | findViewById(R.id.get_music).setOnClickListener(new View.OnClickListener() { 118 | 119 | @Override 120 | public void onClick(View v) { 121 | WXMusicObject music = new WXMusicObject(); 122 | music.musicUrl = "http://www.baidu.com"; 123 | 124 | WXMediaMessage msg = new WXMediaMessage(); 125 | msg.mediaObject = music; 126 | msg.title = "Music Title"; 127 | msg.description = "Music Album"; 128 | 129 | Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); 130 | msg.thumbData = Util.bmpToByteArray(thumb, true); 131 | 132 | GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp(); 133 | resp.transaction = getTransaction(); 134 | resp.message = msg; 135 | 136 | api.sendResp(resp); 137 | finish(); 138 | } 139 | }); 140 | 141 | findViewById(R.id.get_video).setOnClickListener(new View.OnClickListener() { 142 | 143 | @Override 144 | public void onClick(View v) { 145 | WXVideoObject video = new WXVideoObject(); 146 | video.videoUrl = "http://www.baidu.com"; 147 | 148 | WXMediaMessage msg = new WXMediaMessage(video); 149 | msg.title = "Video Title"; 150 | msg.description = "Video Description"; 151 | 152 | GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp(); 153 | resp.transaction = getTransaction(); 154 | resp.message = msg; 155 | 156 | api.sendResp(resp); 157 | finish(); 158 | } 159 | }); 160 | 161 | findViewById(R.id.get_webpage).setOnClickListener(new View.OnClickListener() { 162 | 163 | @Override 164 | public void onClick(View v) { 165 | WXWebpageObject webpage = new WXWebpageObject(); 166 | webpage.webpageUrl = "http://www.baidu.com"; 167 | 168 | WXMediaMessage msg = new WXMediaMessage(webpage); 169 | msg.title = "WebPage Title"; 170 | msg.description = "WebPage Description"; 171 | 172 | GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp(); 173 | resp.transaction = getTransaction(); 174 | resp.message = msg; 175 | 176 | api.sendResp(resp); 177 | finish(); 178 | } 179 | }); 180 | 181 | findViewById(R.id.get_appdata).setOnClickListener(new View.OnClickListener() { 182 | 183 | @Override 184 | public void onClick(View v) { 185 | // respond with appdata by taking photo 186 | CameraUtil.takePhoto(GetFromWXActivity.this, "/mnt/sdcard/tencent/", "get_appdata", 0x100); 187 | } 188 | }); 189 | } 190 | 191 | // @Override 192 | // protected int getLayoutId() { 193 | // return R.layout.get_from_wx; 194 | // } 195 | 196 | @Override 197 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 198 | super.onActivityResult(requestCode, resultCode, data); 199 | 200 | switch (requestCode) { 201 | case 0x100: { 202 | if (resultCode == RESULT_OK) { 203 | final WXAppExtendObject appdata = new WXAppExtendObject(); 204 | final String path = CameraUtil.getResultPhotoPath(this, data, "/mnt/sdcard/tencent/"); 205 | appdata.filePath = path; 206 | appdata.extInfo = "this is ext info"; 207 | 208 | final WXMediaMessage msg = new WXMediaMessage(); 209 | msg.setThumbImage(Util.extractThumbNail(path, 150, 150, true)); 210 | msg.title = "this is title"; 211 | msg.description = "this is description"; 212 | msg.mediaObject = appdata; 213 | 214 | 215 | GetMessageFromWX.Resp resp = new GetMessageFromWX.Resp(); 216 | resp.transaction = getTransaction(); 217 | resp.message = msg; 218 | 219 | api.sendResp(resp); 220 | finish(); 221 | } 222 | break; 223 | } 224 | 225 | default: 226 | break; 227 | } 228 | } 229 | 230 | private String getTransaction() { 231 | final GetMessageFromWX.Req req = new GetMessageFromWX.Req(bundle); 232 | return req.transaction; 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/MD5.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | import java.security.MessageDigest; 4 | 5 | public class MD5 { 6 | 7 | private MD5() {} 8 | 9 | public final static String getMessageDigest(byte[] buffer) { 10 | char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 11 | try { 12 | MessageDigest mdTemp = MessageDigest.getInstance("MD5"); 13 | mdTemp.update(buffer); 14 | byte[] md = mdTemp.digest(); 15 | int j = md.length; 16 | char str[] = new char[j * 2]; 17 | int k = 0; 18 | for (int i = 0; i < j; i++) { 19 | byte byte0 = md[i]; 20 | str[k++] = hexDigits[byte0 >>> 4 & 0xf]; 21 | str[k++] = hexDigits[byte0 & 0xf]; 22 | } 23 | return new String(str); 24 | } catch (Exception e) { 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/PayActivity.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | 4 | import android.app.Activity; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.util.Log; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.Toast; 11 | 12 | import com.tencent.mm.opensdk.constants.Build; 13 | import com.tencent.mm.opensdk.modelpay.PayReq; 14 | import com.tencent.mm.opensdk.openapi.IWXAPI; 15 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 16 | 17 | import org.json.JSONException; 18 | import org.json.JSONObject; 19 | 20 | public class PayActivity extends Activity { 21 | 22 | private IWXAPI api; 23 | private Handler handler = new Handler(); 24 | Button appayBtn; 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.pay); 29 | 30 | api = WXAPIFactory.createWXAPI(this, "wxb4ba3c02aa476ea1"); 31 | 32 | appayBtn = (Button) findViewById(R.id.appay_btn); 33 | appayBtn.setOnClickListener(new View.OnClickListener() { 34 | 35 | @Override 36 | public void onClick(View v) { 37 | appayBtn = (Button) findViewById(R.id.appay_btn); 38 | appayBtn.setEnabled(false); 39 | Toast.makeText(PayActivity.this, "获取订单中...", Toast.LENGTH_SHORT).show(); 40 | payThread.start(); 41 | } 42 | }); 43 | Button checkPayBtn = (Button) findViewById(R.id.check_pay_btn); 44 | checkPayBtn.setOnClickListener(new View.OnClickListener() { 45 | 46 | @Override 47 | public void onClick(View v) { 48 | boolean isPaySupported = api.getWXAppSupportAPI() >= Build.PAY_SUPPORTED_SDK_INT; 49 | Toast.makeText(PayActivity.this, String.valueOf(isPaySupported), Toast.LENGTH_SHORT).show(); 50 | } 51 | }); 52 | } 53 | 54 | Thread payThread = new Thread(new Runnable() { 55 | @Override 56 | public void run() { 57 | String url = "https://wxpay.wxutil.com/pub_v2/app/app_pay.php"; 58 | try{ 59 | byte[] buf = Util.httpGet(url); 60 | if (buf != null && buf.length > 0) { 61 | String content = new String(buf); 62 | Log.e("get server pay params:",content); 63 | final JSONObject json = new JSONObject(content); 64 | if(null != json && !json.has("retcode") ){ 65 | PayReq req = new PayReq(); 66 | //req.appId = "wxf8b4f85f3a794e77"; // 测试用appId 67 | req.appId = json.getString("appid"); 68 | req.partnerId = json.getString("partnerid"); 69 | req.prepayId = json.getString("prepayid"); 70 | req.nonceStr = json.getString("noncestr"); 71 | req.timeStamp = json.getString("timestamp"); 72 | req.packageValue = json.getString("package"); 73 | req.sign = json.getString("sign"); 74 | req.extData = "app data"; // optional 75 | handler.post(new Runnable() { 76 | @Override 77 | public void run() { 78 | Toast.makeText(PayActivity.this, "正常调起支付", Toast.LENGTH_SHORT).show(); 79 | } 80 | }); 81 | // 在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信 82 | api.sendReq(req); 83 | }else{ 84 | Log.d("PAY_GET", "返回错误"+json.getString("retmsg")); 85 | handler.post(new Runnable() { 86 | @Override 87 | public void run() { 88 | try { 89 | Toast.makeText(PayActivity.this, "返回错误"+json.getString("retmsg"), Toast.LENGTH_SHORT).show(); 90 | } catch (JSONException e) { 91 | e.printStackTrace(); 92 | } 93 | } 94 | }); 95 | } 96 | }else{ 97 | Log.d("PAY_GET", "服务器请求错误"); 98 | handler.post(new Runnable() { 99 | @Override 100 | public void run() { 101 | Toast.makeText(PayActivity.this, "服务器请求错误", Toast.LENGTH_SHORT).show(); 102 | } 103 | }); 104 | } 105 | }catch(final Exception e){ 106 | Log.e("PAY_GET", "异常:"+e.getMessage()); 107 | handler.post(new Runnable() { 108 | @Override 109 | public void run() { 110 | Toast.makeText(PayActivity.this, "异常:"+e.getMessage(), Toast.LENGTH_SHORT).show(); 111 | } 112 | }); 113 | } 114 | handler.post(new Runnable() { 115 | @Override 116 | public void run() { 117 | appayBtn.setEnabled(true); 118 | } 119 | }); 120 | } 121 | }); 122 | } 123 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/SendToWXActivity.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | import android.app.Activity; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.os.Environment; 10 | import android.view.View; 11 | import android.widget.CheckBox; 12 | import android.widget.EditText; 13 | import android.widget.LinearLayout; 14 | import android.widget.Toast; 15 | 16 | import com.tencent.mm.opensdk.modelmsg.SendAuth; 17 | import com.tencent.mm.opensdk.modelmsg.SendMessageToWX; 18 | import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject; 19 | import com.tencent.mm.opensdk.modelmsg.WXEmojiObject; 20 | import com.tencent.mm.opensdk.modelmsg.WXImageObject; 21 | import com.tencent.mm.opensdk.modelmsg.WXMediaMessage; 22 | import com.tencent.mm.opensdk.modelmsg.WXMusicObject; 23 | import com.tencent.mm.opensdk.modelmsg.WXTextObject; 24 | import com.tencent.mm.opensdk.modelmsg.WXVideoObject; 25 | import com.tencent.mm.opensdk.modelmsg.WXWebpageObject; 26 | import com.tencent.mm.opensdk.openapi.IWXAPI; 27 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 28 | 29 | import net.sourceforge.simcpux.uikit.CameraUtil; 30 | import net.sourceforge.simcpux.uikit.MMAlert; 31 | 32 | import java.io.File; 33 | import java.net.URL; 34 | 35 | public class SendToWXActivity extends Activity { 36 | 37 | private static final int THUMB_SIZE = 150; 38 | 39 | private static final String SDCARD_ROOT = Environment.getExternalStorageDirectory().getAbsolutePath(); 40 | 41 | private IWXAPI api; 42 | private static final int MMAlertSelect1 = 0; 43 | private static final int MMAlertSelect2 = 1; 44 | private static final int MMAlertSelect3 = 2; 45 | 46 | private CheckBox isTimelineCb; 47 | 48 | @Override 49 | public void onCreate(Bundle savedInstanceState) { 50 | super.onCreate(savedInstanceState); 51 | 52 | api = WXAPIFactory.createWXAPI(this, Constants.APP_ID); 53 | 54 | setContentView(R.layout.send_to_wx); 55 | initView(); 56 | } 57 | 58 | private void initView() { 59 | 60 | isTimelineCb = (CheckBox) findViewById(R.id.is_timeline_cb); 61 | isTimelineCb.setChecked(false); 62 | 63 | // send to weixin 64 | findViewById(R.id.send_text).setOnClickListener(new View.OnClickListener() { 65 | 66 | @Override 67 | public void onClick(View v) { 68 | 69 | final EditText editor = new EditText(SendToWXActivity.this); 70 | editor.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); 71 | editor.setText(R.string.send_text_default); 72 | 73 | MMAlert.showAlert(SendToWXActivity.this, "send text", editor, getString(R.string.app_share), getString(R.string.app_cancel), new DialogInterface.OnClickListener() { 74 | 75 | @Override 76 | public void onClick(DialogInterface dialog, int which) { 77 | String text = editor.getText().toString(); 78 | if (text == null || text.length() == 0) { 79 | return; 80 | } 81 | 82 | // 初始化一个WXTextObject对象 83 | WXTextObject textObj = new WXTextObject(); 84 | textObj.text = text; 85 | 86 | // 用WXTextObject对象初始化一个WXMediaMessage对象 87 | WXMediaMessage msg = new WXMediaMessage(); 88 | msg.mediaObject = textObj; 89 | // 发送文本类型的消息时,title字段不起作用 90 | // msg.title = "Will be ignored"; 91 | msg.description = text; 92 | 93 | // 构造一个Req 94 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 95 | req.transaction = buildTransaction("text"); // transaction字段用于唯一标识一个请求 96 | req.message = msg; 97 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 98 | req.openId = getOpenId(); 99 | // 调用api接口发送数据到微信 100 | api.sendReq(req); 101 | finish(); 102 | } 103 | }, null); 104 | } 105 | }); 106 | 107 | findViewById(R.id.send_img).setOnClickListener(new View.OnClickListener() { 108 | 109 | @Override 110 | public void onClick(View v) { 111 | MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_img), 112 | SendToWXActivity.this.getResources().getStringArray(R.array.send_img_item), 113 | null, new MMAlert.OnAlertSelectId(){ 114 | 115 | @Override 116 | public void onClick(int whichButton) { 117 | switch(whichButton){ 118 | case MMAlertSelect1: { 119 | Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.send_img); 120 | WXImageObject imgObj = new WXImageObject(bmp); 121 | 122 | WXMediaMessage msg = new WXMediaMessage(); 123 | msg.mediaObject = imgObj; 124 | 125 | Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true); 126 | bmp.recycle(); 127 | msg.thumbData = Util.bmpToByteArray(thumbBmp, true); // 设置缩略图 128 | 129 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 130 | req.transaction = buildTransaction("img"); 131 | req.message = msg; 132 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 133 | req.openId = getOpenId(); 134 | api.sendReq(req); 135 | 136 | finish(); 137 | break; 138 | } 139 | case MMAlertSelect2: { 140 | String path = SDCARD_ROOT + "/test.png"; 141 | File file = new File(path); 142 | if (!file.exists()) { 143 | String tip = SendToWXActivity.this.getString(R.string.send_img_file_not_exist); 144 | Toast.makeText(SendToWXActivity.this, tip + " path = " + path, Toast.LENGTH_LONG).show(); 145 | break; 146 | } 147 | 148 | WXImageObject imgObj = new WXImageObject(); 149 | imgObj.setImagePath(path); 150 | 151 | WXMediaMessage msg = new WXMediaMessage(); 152 | msg.mediaObject = imgObj; 153 | 154 | Bitmap bmp = BitmapFactory.decodeFile(path); 155 | Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true); 156 | bmp.recycle(); 157 | msg.thumbData = Util.bmpToByteArray(thumbBmp, true); 158 | 159 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 160 | req.transaction = buildTransaction("img"); 161 | req.message = msg; 162 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 163 | req.openId = getOpenId(); 164 | api.sendReq(req); 165 | 166 | finish(); 167 | break; 168 | } 169 | case MMAlertSelect3: { 170 | String url = "http://weixin.qq.com/zh_CN/htmledition/images/weixin/weixin_logo0d1938.png"; 171 | 172 | try{ 173 | WXImageObject imgObj = new WXImageObject(); 174 | imgObj.imagePath = url; 175 | 176 | WXMediaMessage msg = new WXMediaMessage(); 177 | msg.mediaObject = imgObj; 178 | 179 | Bitmap bmp = BitmapFactory.decodeStream(new URL(url).openStream()); 180 | Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true); 181 | bmp.recycle(); 182 | msg.thumbData = Util.bmpToByteArray(thumbBmp, true); 183 | 184 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 185 | req.transaction = buildTransaction("img"); 186 | req.message = msg; 187 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 188 | req.openId = getOpenId(); 189 | api.sendReq(req); 190 | 191 | finish(); 192 | } catch(Exception e) { 193 | e.printStackTrace(); 194 | } 195 | 196 | break; 197 | } 198 | default: 199 | break; 200 | } 201 | } 202 | 203 | }); 204 | } 205 | }); 206 | 207 | findViewById(R.id.send_music).setOnClickListener(new View.OnClickListener() { 208 | 209 | @Override 210 | public void onClick(View v) { 211 | 212 | MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_music), 213 | SendToWXActivity.this.getResources().getStringArray(R.array.send_music_item), 214 | null, new MMAlert.OnAlertSelectId(){ 215 | 216 | @Override 217 | public void onClick(int whichButton) { 218 | switch(whichButton){ 219 | case MMAlertSelect1: { 220 | WXMusicObject music = new WXMusicObject(); 221 | //music.musicUrl = "http://www.baidu.com"; 222 | music.musicUrl="http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"; 223 | //music.musicUrl="http://120.196.211.49/XlFNM14sois/AKVPrOJ9CBnIN556OrWEuGhZvlDF02p5zIXwrZqLUTti4o6MOJ4g7C6FPXmtlh6vPtgbKQ==/31353278.mp3"; 224 | 225 | WXMediaMessage msg = new WXMediaMessage(); 226 | msg.mediaObject = music; 227 | msg.title = "Music Title Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; 228 | msg.description = "Music Album Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; 229 | 230 | Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); 231 | msg.thumbData = Util.bmpToByteArray(thumb, true); 232 | 233 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 234 | req.transaction = buildTransaction("music"); 235 | req.message = msg; 236 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 237 | req.openId = getOpenId(); 238 | api.sendReq(req); 239 | 240 | finish(); 241 | break; 242 | } 243 | case MMAlertSelect2: { 244 | WXMusicObject music = new WXMusicObject(); 245 | music.musicLowBandUrl = "http://www.qq.com"; 246 | 247 | WXMediaMessage msg = new WXMediaMessage(); 248 | msg.mediaObject = music; 249 | msg.title = "Music Title"; 250 | msg.description = "Music Album"; 251 | 252 | Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); 253 | msg.thumbData = Util.bmpToByteArray(thumb, true); 254 | 255 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 256 | req.transaction = buildTransaction("music"); 257 | req.message = msg; 258 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 259 | req.openId = getOpenId(); 260 | api.sendReq(req); 261 | 262 | finish(); 263 | break; 264 | } 265 | default: 266 | break; 267 | } 268 | } 269 | }); 270 | } 271 | }); 272 | 273 | findViewById(R.id.send_video).setOnClickListener(new View.OnClickListener() { 274 | 275 | @Override 276 | public void onClick(View v) { 277 | MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_video), 278 | SendToWXActivity.this.getResources().getStringArray(R.array.send_video_item), 279 | null, new MMAlert.OnAlertSelectId(){ 280 | 281 | @Override 282 | public void onClick(int whichButton) { 283 | switch(whichButton){ 284 | case MMAlertSelect1: { 285 | WXVideoObject video = new WXVideoObject(); 286 | video.videoUrl = "http://www.baidu.com"; 287 | 288 | WXMediaMessage msg = new WXMediaMessage(video); 289 | msg.title = "Video Title Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; 290 | msg.description = "Video Description Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; 291 | Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); 292 | msg.thumbData = Util.bmpToByteArray(thumb, true); 293 | 294 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 295 | req.transaction = buildTransaction("video"); 296 | req.message = msg; 297 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 298 | req.openId = getOpenId(); 299 | api.sendReq(req); 300 | 301 | finish(); 302 | break; 303 | } 304 | case MMAlertSelect2: { 305 | WXVideoObject video = new WXVideoObject(); 306 | video.videoLowBandUrl = "http://www.qq.com"; 307 | 308 | WXMediaMessage msg = new WXMediaMessage(video); 309 | msg.title = "Video Title"; 310 | msg.description = "Video Description"; 311 | 312 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 313 | req.transaction = buildTransaction("video"); 314 | req.message = msg; 315 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 316 | req.openId = getOpenId(); 317 | api.sendReq(req); 318 | 319 | finish(); 320 | break; 321 | } 322 | default: 323 | break; 324 | } 325 | } 326 | }); 327 | } 328 | }); 329 | 330 | findViewById(R.id.send_webpage).setOnClickListener(new View.OnClickListener() { 331 | 332 | @Override 333 | public void onClick(View v) { 334 | MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_webpage), 335 | SendToWXActivity.this.getResources().getStringArray(R.array.send_webpage_item), 336 | null, new MMAlert.OnAlertSelectId(){ 337 | 338 | @Override 339 | public void onClick(int whichButton) { 340 | switch(whichButton){ 341 | case MMAlertSelect1: 342 | WXWebpageObject webpage = new WXWebpageObject(); 343 | webpage.webpageUrl = "http://www.baidu.com"; 344 | WXMediaMessage msg = new WXMediaMessage(webpage); 345 | msg.title = "WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; 346 | msg.description = "WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description Very Long Very Long Very Long Very Long Very Long Very Long Very Long"; 347 | Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); 348 | msg.thumbData = Util.bmpToByteArray(thumb, true); 349 | 350 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 351 | req.transaction = buildTransaction("webpage"); 352 | req.message = msg; 353 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 354 | req.openId = getOpenId(); 355 | api.sendReq(req); 356 | 357 | finish(); 358 | break; 359 | default: 360 | break; 361 | } 362 | } 363 | }); 364 | } 365 | }); 366 | 367 | findViewById(R.id.send_appdata).setOnClickListener(new View.OnClickListener() { 368 | 369 | @Override 370 | public void onClick(View v) { 371 | MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_appdata), 372 | SendToWXActivity.this.getResources().getStringArray(R.array.send_appdata_item), 373 | null, new MMAlert.OnAlertSelectId(){ 374 | 375 | @Override 376 | public void onClick(int whichButton) { 377 | switch(whichButton){ 378 | case MMAlertSelect1: 379 | final String dir = SDCARD_ROOT + "/tencent/"; 380 | File file = new File(dir); 381 | if (!file.exists()) { 382 | file.mkdirs(); 383 | } 384 | CameraUtil.takePhoto(SendToWXActivity.this, dir, "send_appdata", 0x101); 385 | break; 386 | case MMAlertSelect2: { 387 | final WXAppExtendObject appdata = new WXAppExtendObject(); 388 | final String path = SDCARD_ROOT + "/test.png"; 389 | appdata.fileData = Util.readFromFile(path, 0, -1); 390 | appdata.extInfo = "this is ext info"; 391 | 392 | final WXMediaMessage msg = new WXMediaMessage(); 393 | msg.setThumbImage(Util.extractThumbNail(path, 150, 150, true)); 394 | msg.title = "this is title"; 395 | msg.description = "this is description sjgksgj sklgjl sjgsgskl gslgj sklgj sjglsjgs kl gjksss ssssssss sjskgs kgjsj jskgjs kjgk sgjsk Very Long Very Long Very Long Very Longgj skjgks kgsk lgskg jslgj"; 396 | msg.mediaObject = appdata; 397 | 398 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 399 | req.transaction = buildTransaction("appdata"); 400 | req.message = msg; 401 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 402 | req.openId = getOpenId(); 403 | api.sendReq(req); 404 | 405 | finish(); 406 | break; 407 | } 408 | case MMAlertSelect3: { 409 | // send appdata with no attachment 410 | final WXAppExtendObject appdata = new WXAppExtendObject(); 411 | appdata.extInfo = "this is ext info"; 412 | final WXMediaMessage msg = new WXMediaMessage(); 413 | msg.title = "this is title"; 414 | msg.description = "this is description"; 415 | msg.mediaObject = appdata; 416 | 417 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 418 | req.transaction = buildTransaction("appdata"); 419 | req.message = msg; 420 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 421 | req.openId = getOpenId(); 422 | api.sendReq(req); 423 | 424 | finish(); 425 | break; 426 | } 427 | default: 428 | break; 429 | } 430 | } 431 | 432 | }); 433 | } 434 | }); 435 | 436 | findViewById(R.id.send_emoji).setOnClickListener(new View.OnClickListener() { 437 | 438 | @Override 439 | public void onClick(View v) { 440 | MMAlert.showAlert(SendToWXActivity.this, getString(R.string.send_emoji), 441 | SendToWXActivity.this.getResources().getStringArray(R.array.send_emoji_item), 442 | null, new MMAlert.OnAlertSelectId(){ 443 | 444 | @Override 445 | public void onClick(int whichButton) { 446 | final String EMOJI_FILE_PATH = SDCARD_ROOT + "/emoji.gif"; 447 | final String EMOJI_FILE_THUMB_PATH = SDCARD_ROOT + "/emojithumb.jpg"; 448 | switch(whichButton){ 449 | case MMAlertSelect1: { 450 | WXEmojiObject emoji = new WXEmojiObject(); 451 | emoji.emojiPath = EMOJI_FILE_PATH; 452 | 453 | WXMediaMessage msg = new WXMediaMessage(emoji); 454 | msg.title = "Emoji Title"; 455 | msg.description = "Emoji Description"; 456 | msg.thumbData = Util.readFromFile(EMOJI_FILE_THUMB_PATH, 0, (int) new File(EMOJI_FILE_THUMB_PATH).length()); 457 | 458 | 459 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 460 | req.transaction = buildTransaction("emoji"); 461 | req.message = msg; 462 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 463 | req.openId = getOpenId(); 464 | api.sendReq(req); 465 | 466 | finish(); 467 | break; 468 | } 469 | 470 | case MMAlertSelect2: { 471 | WXEmojiObject emoji = new WXEmojiObject(); 472 | emoji.emojiData = Util.readFromFile(EMOJI_FILE_PATH, 0, (int) new File(EMOJI_FILE_PATH).length()); 473 | WXMediaMessage msg = new WXMediaMessage(emoji); 474 | 475 | msg.title = "Emoji Title"; 476 | msg.description = "Emoji Description"; 477 | msg.thumbData = Util.readFromFile(EMOJI_FILE_THUMB_PATH, 0, (int) new File(EMOJI_FILE_THUMB_PATH).length()); 478 | 479 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 480 | req.transaction = buildTransaction("emoji"); 481 | req.message = msg; 482 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 483 | req.openId = getOpenId(); 484 | api.sendReq(req); 485 | 486 | finish(); 487 | break; 488 | } 489 | default: 490 | break; 491 | } 492 | } 493 | }); 494 | } 495 | }); 496 | 497 | // get token 498 | findViewById(R.id.get_token).setOnClickListener(new View.OnClickListener() { 499 | 500 | @Override 501 | public void onClick(View v) { 502 | EditText scopeEt = (EditText) findViewById(R.id.get_token_scope_et); 503 | String scope = scopeEt.getText().toString(); 504 | if (scope == null || scope.length() == 0) { 505 | scope = "snsapi_userinfo"; 506 | } 507 | 508 | // send oauth request 509 | final SendAuth.Req req = new SendAuth.Req(); 510 | req.scope = scope; 511 | req.state = "none"; 512 | req.openId = getOpenId(); 513 | api.sendReq(req); 514 | finish(); 515 | } 516 | }); 517 | 518 | // unregister from weixin 519 | findViewById(R.id.unregister).setOnClickListener(new View.OnClickListener() { 520 | 521 | @Override 522 | public void onClick(View v) { 523 | api.unregisterApp(); 524 | } 525 | }); 526 | } 527 | 528 | @Override 529 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 530 | super.onActivityResult(requestCode, resultCode, data); 531 | 532 | switch (requestCode) { 533 | 534 | case 0x101: { 535 | final WXAppExtendObject appdata = new WXAppExtendObject(); 536 | final String path = CameraUtil.getResultPhotoPath(this, data, SDCARD_ROOT + "/tencent/"); 537 | appdata.filePath = path; 538 | appdata.extInfo = "this is ext info"; 539 | 540 | final WXMediaMessage msg = new WXMediaMessage(); 541 | msg.setThumbImage(Util.extractThumbNail(path, 150, 150, true)); 542 | msg.title = "this is title"; 543 | msg.description = "this is description"; 544 | msg.mediaObject = appdata; 545 | 546 | SendMessageToWX.Req req = new SendMessageToWX.Req(); 547 | req.transaction = buildTransaction("appdata"); 548 | req.message = msg; 549 | req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; 550 | req.openId = getOpenId(); 551 | api.sendReq(req); 552 | 553 | finish(); 554 | break; 555 | } 556 | default: 557 | break; 558 | } 559 | } 560 | 561 | private String buildTransaction(final String type) { 562 | return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis(); 563 | } 564 | 565 | // supported during Build.OPENID_SUPPORTED_SDK_INT = 0x22000001 566 | private String getOpenId() { 567 | EditText openIdEt = (EditText) findViewById(R.id.openid_et); 568 | return openIdEt.getText().toString(); 569 | } 570 | } 571 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/ShowFromWXActivity.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | import net.sourceforge.simcpux.R; 4 | 5 | import android.app.Activity; 6 | import android.app.AlertDialog; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.widget.ImageView; 10 | 11 | public class ShowFromWXActivity extends Activity { 12 | 13 | @Override 14 | public void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | 17 | setContentView(R.layout.show_from_wx); 18 | initView(); 19 | } 20 | 21 | private void initView() { 22 | 23 | final String title = getIntent().getStringExtra(Constants.ShowMsgActivity.STitle); 24 | final String message = getIntent().getStringExtra(Constants.ShowMsgActivity.SMessage); 25 | final byte[] thumbData = getIntent().getByteArrayExtra(Constants.ShowMsgActivity.BAThumbData); 26 | 27 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 28 | builder.setTitle(title); 29 | builder.setMessage(message); 30 | 31 | if (thumbData != null && thumbData.length > 0) { 32 | ImageView thumbIv = new ImageView(this); 33 | thumbIv.setImageBitmap(BitmapFactory.decodeByteArray(thumbData, 0, thumbData.length)); 34 | builder.setView(thumbIv); 35 | } 36 | 37 | builder.show(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/Util.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.io.RandomAccessFile; 7 | import java.net.Socket; 8 | import java.net.UnknownHostException; 9 | import java.security.KeyManagementException; 10 | import java.security.KeyStore; 11 | import java.security.KeyStoreException; 12 | import java.security.MessageDigest; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.UnrecoverableKeyException; 15 | import java.security.cert.X509Certificate; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import javax.net.ssl.SSLContext; 20 | import javax.net.ssl.TrustManager; 21 | import javax.net.ssl.X509TrustManager; 22 | 23 | import org.apache.http.HttpResponse; 24 | import org.apache.http.HttpStatus; 25 | import org.apache.http.HttpVersion; 26 | import org.apache.http.client.HttpClient; 27 | import org.apache.http.client.methods.HttpGet; 28 | import org.apache.http.client.methods.HttpPost; 29 | import org.apache.http.conn.ClientConnectionManager; 30 | import org.apache.http.conn.scheme.PlainSocketFactory; 31 | import org.apache.http.conn.scheme.Scheme; 32 | import org.apache.http.conn.scheme.SchemeRegistry; 33 | import org.apache.http.conn.ssl.SSLSocketFactory; 34 | import org.apache.http.entity.StringEntity; 35 | import org.apache.http.impl.client.DefaultHttpClient; 36 | import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; 37 | import org.apache.http.params.BasicHttpParams; 38 | import org.apache.http.params.HttpParams; 39 | import org.apache.http.params.HttpProtocolParams; 40 | import org.apache.http.protocol.HTTP; 41 | import org.apache.http.util.EntityUtils; 42 | 43 | import junit.framework.Assert; 44 | 45 | import android.graphics.Bitmap; 46 | import android.graphics.BitmapFactory; 47 | import android.graphics.Bitmap.CompressFormat; 48 | import android.util.Log; 49 | 50 | public class Util { 51 | 52 | private static final String TAG = "SDK_Sample.Util"; 53 | 54 | public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) { 55 | ByteArrayOutputStream output = new ByteArrayOutputStream(); 56 | bmp.compress(CompressFormat.PNG, 100, output); 57 | if (needRecycle) { 58 | bmp.recycle(); 59 | } 60 | 61 | byte[] result = output.toByteArray(); 62 | try { 63 | output.close(); 64 | } catch (Exception e) { 65 | e.printStackTrace(); 66 | } 67 | 68 | return result; 69 | } 70 | 71 | public static byte[] httpGet(final String url) { 72 | if (url == null || url.length() == 0) { 73 | Log.e(TAG, "httpGet, url is null"); 74 | return null; 75 | } 76 | 77 | HttpClient httpClient = getNewHttpClient(); 78 | HttpGet httpGet = new HttpGet(url); 79 | 80 | try { 81 | HttpResponse resp = httpClient.execute(httpGet); 82 | if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { 83 | Log.e(TAG, "httpGet fail, status code = " + resp.getStatusLine().getStatusCode()); 84 | return null; 85 | } 86 | 87 | return EntityUtils.toByteArray(resp.getEntity()); 88 | 89 | } catch (Exception e) { 90 | Log.e(TAG, "httpGet exception, e = " + e.getMessage()); 91 | e.printStackTrace(); 92 | return null; 93 | } 94 | } 95 | 96 | public static byte[] httpPost(String url, String entity) { 97 | if (url == null || url.length() == 0) { 98 | Log.e(TAG, "httpPost, url is null"); 99 | return null; 100 | } 101 | 102 | HttpClient httpClient = getNewHttpClient(); 103 | 104 | HttpPost httpPost = new HttpPost(url); 105 | 106 | try { 107 | httpPost.setEntity(new StringEntity(entity)); 108 | httpPost.setHeader("Accept", "application/json"); 109 | httpPost.setHeader("Content-type", "application/json"); 110 | 111 | HttpResponse resp = httpClient.execute(httpPost); 112 | if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { 113 | Log.e(TAG, "httpGet fail, status code = " + resp.getStatusLine().getStatusCode()); 114 | return null; 115 | } 116 | 117 | return EntityUtils.toByteArray(resp.getEntity()); 118 | } catch (Exception e) { 119 | Log.e(TAG, "httpPost exception, e = " + e.getMessage()); 120 | e.printStackTrace(); 121 | return null; 122 | } 123 | } 124 | 125 | private static class SSLSocketFactoryEx extends SSLSocketFactory { 126 | 127 | SSLContext sslContext = SSLContext.getInstance("TLS"); 128 | 129 | public SSLSocketFactoryEx(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { 130 | super(truststore); 131 | 132 | TrustManager tm = new X509TrustManager() { 133 | 134 | public X509Certificate[] getAcceptedIssuers() { 135 | return null; 136 | } 137 | 138 | @Override 139 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws java.security.cert.CertificateException { 140 | } 141 | 142 | @Override 143 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws java.security.cert.CertificateException { 144 | } 145 | }; 146 | 147 | sslContext.init(null, new TrustManager[] { tm }, null); 148 | } 149 | 150 | @Override 151 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { 152 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); 153 | } 154 | 155 | @Override 156 | public Socket createSocket() throws IOException { 157 | return sslContext.getSocketFactory().createSocket(); 158 | } 159 | } 160 | 161 | private static HttpClient getNewHttpClient() { 162 | try { 163 | KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); 164 | trustStore.load(null, null); 165 | 166 | SSLSocketFactory sf = new SSLSocketFactoryEx(trustStore); 167 | sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); 168 | 169 | HttpParams params = new BasicHttpParams(); 170 | HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); 171 | HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); 172 | 173 | SchemeRegistry registry = new SchemeRegistry(); 174 | registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); 175 | registry.register(new Scheme("https", sf, 443)); 176 | 177 | ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); 178 | 179 | return new DefaultHttpClient(ccm, params); 180 | } catch (Exception e) { 181 | return new DefaultHttpClient(); 182 | } 183 | } 184 | 185 | public static byte[] readFromFile(String fileName, int offset, int len) { 186 | if (fileName == null) { 187 | return null; 188 | } 189 | 190 | File file = new File(fileName); 191 | if (!file.exists()) { 192 | Log.i(TAG, "readFromFile: file not found"); 193 | return null; 194 | } 195 | 196 | if (len == -1) { 197 | len = (int) file.length(); 198 | } 199 | 200 | Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len)); 201 | 202 | if(offset <0){ 203 | Log.e(TAG, "readFromFile invalid offset:" + offset); 204 | return null; 205 | } 206 | if(len <=0 ){ 207 | Log.e(TAG, "readFromFile invalid len:" + len); 208 | return null; 209 | } 210 | if(offset + len > (int) file.length()){ 211 | Log.e(TAG, "readFromFile invalid file len:" + file.length()); 212 | return null; 213 | } 214 | 215 | byte[] b = null; 216 | try { 217 | RandomAccessFile in = new RandomAccessFile(fileName, "r"); 218 | b = new byte[len]; // 创建合适文件大小的数组 219 | in.seek(offset); 220 | in.readFully(b); 221 | in.close(); 222 | 223 | } catch (Exception e) { 224 | Log.e(TAG, "readFromFile : errMsg = " + e.getMessage()); 225 | e.printStackTrace(); 226 | } 227 | return b; 228 | } 229 | 230 | private static final int MAX_DECODE_PICTURE_SIZE = 1920 * 1440; 231 | public static Bitmap extractThumbNail(final String path, final int height, final int width, final boolean crop) { 232 | Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0); 233 | 234 | BitmapFactory.Options options = new BitmapFactory.Options(); 235 | 236 | try { 237 | options.inJustDecodeBounds = true; 238 | Bitmap tmp = BitmapFactory.decodeFile(path, options); 239 | if (tmp != null) { 240 | tmp.recycle(); 241 | tmp = null; 242 | } 243 | 244 | Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop); 245 | final double beY = options.outHeight * 1.0 / height; 246 | final double beX = options.outWidth * 1.0 / width; 247 | Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY); 248 | options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY)); 249 | if (options.inSampleSize <= 1) { 250 | options.inSampleSize = 1; 251 | } 252 | 253 | // NOTE: out of memory error 254 | while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) { 255 | options.inSampleSize++; 256 | } 257 | 258 | int newHeight = height; 259 | int newWidth = width; 260 | if (crop) { 261 | if (beY > beX) { 262 | newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth); 263 | } else { 264 | newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight); 265 | } 266 | } else { 267 | if (beY < beX) { 268 | newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth); 269 | } else { 270 | newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight); 271 | } 272 | } 273 | 274 | options.inJustDecodeBounds = false; 275 | 276 | Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize); 277 | Bitmap bm = BitmapFactory.decodeFile(path, options); 278 | if (bm == null) { 279 | Log.e(TAG, "bitmap decode failed"); 280 | return null; 281 | } 282 | 283 | Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight()); 284 | final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true); 285 | if (scale != null) { 286 | bm.recycle(); 287 | bm = scale; 288 | } 289 | 290 | if (crop) { 291 | final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height); 292 | if (cropped == null) { 293 | return bm; 294 | } 295 | 296 | bm.recycle(); 297 | bm = cropped; 298 | Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight()); 299 | } 300 | return bm; 301 | 302 | } catch (final OutOfMemoryError e) { 303 | Log.e(TAG, "decode bitmap failed: " + e.getMessage()); 304 | options = null; 305 | } 306 | 307 | return null; 308 | } 309 | 310 | public static String sha1(String str) { 311 | if (str == null || str.length() == 0) { 312 | return null; 313 | } 314 | 315 | char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 316 | 317 | try { 318 | MessageDigest mdTemp = MessageDigest.getInstance("SHA1"); 319 | mdTemp.update(str.getBytes()); 320 | 321 | byte[] md = mdTemp.digest(); 322 | int j = md.length; 323 | char buf[] = new char[j * 2]; 324 | int k = 0; 325 | for (int i = 0; i < j; i++) { 326 | byte byte0 = md[i]; 327 | buf[k++] = hexDigits[byte0 >>> 4 & 0xf]; 328 | buf[k++] = hexDigits[byte0 & 0xf]; 329 | } 330 | return new String(buf); 331 | } catch (Exception e) { 332 | return null; 333 | } 334 | } 335 | 336 | public static List stringsToList(final String[] src) { 337 | if (src == null || src.length == 0) { 338 | return null; 339 | } 340 | final List result = new ArrayList(); 341 | for (int i = 0; i < src.length; i++) { 342 | result.add(src[i]); 343 | } 344 | return result; 345 | } 346 | } 347 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/uikit/CameraUtil.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux.uikit; 2 | 3 | import java.io.BufferedOutputStream; 4 | import java.io.File; 5 | import java.io.FileOutputStream; 6 | 7 | import net.sourceforge.simcpux.MD5; 8 | 9 | import android.app.Activity; 10 | import android.content.ActivityNotFoundException; 11 | import android.content.Context; 12 | import android.content.Intent; 13 | import android.database.Cursor; 14 | import android.graphics.Bitmap; 15 | import android.net.Uri; 16 | import android.provider.MediaStore; 17 | import android.provider.MediaStore.MediaColumns; 18 | import android.text.format.DateFormat; 19 | import android.util.Log; 20 | 21 | public final class CameraUtil { 22 | 23 | private static final String TAG = "MicroMsg.SDK.CameraUtil"; 24 | private static final String PHOTO_DEFAULT_EXT = ".jpg"; 25 | 26 | private static String filePath = null; 27 | 28 | private CameraUtil() { 29 | // can't be instantiated 30 | } 31 | 32 | public static boolean takePhoto(final Activity activity, final String dir, final String filename, final int cmd) { 33 | filePath = dir + filename; 34 | 35 | final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 36 | final File cameraDir = new File(dir); 37 | if (!cameraDir.exists()) { 38 | return false; 39 | } 40 | 41 | final File file = new File(filePath); 42 | final Uri outputFileUri = Uri.fromFile(file); 43 | intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); 44 | try { 45 | activity.startActivityForResult(intent, cmd); 46 | 47 | } catch (final ActivityNotFoundException e) { 48 | return false; 49 | } 50 | return true; 51 | } 52 | 53 | public static String getResultPhotoPath(Context context, final Intent intent, final String dir) { 54 | if (filePath != null && new File(filePath).exists()) { 55 | return filePath; 56 | } 57 | 58 | return resolvePhotoFromIntent(context, intent, dir); 59 | } 60 | 61 | public static String resolvePhotoFromIntent(final Context ctx, final Intent data, final String dir) { 62 | if (ctx == null || data == null || dir == null) { 63 | Log.e(TAG, "resolvePhotoFromIntent fail, invalid argument"); 64 | return null; 65 | } 66 | 67 | String filePath = null; 68 | 69 | final Uri uri = Uri.parse(data.toURI()); 70 | Cursor cu = ctx.getContentResolver().query(uri, null, null, null, null); 71 | if (cu != null && cu.getCount() > 0) { 72 | try { 73 | cu.moveToFirst(); 74 | final int pathIndex = cu.getColumnIndex(MediaColumns.DATA); 75 | Log.e(TAG, "orition: " + cu.getString(cu.getColumnIndex(MediaStore.Images.ImageColumns.ORIENTATION))); 76 | filePath = cu.getString(pathIndex); 77 | Log.d(TAG, "photo from resolver, path:" + filePath); 78 | 79 | } catch (Exception e) { 80 | e.printStackTrace(); 81 | } 82 | 83 | } else if (data.getData() != null) { 84 | filePath = data.getData().getPath(); 85 | if (!(new File(filePath)).exists()) { 86 | filePath = null; 87 | } 88 | Log.d(TAG, "photo file from data, path:" + filePath); 89 | 90 | } else if (data.getAction() != null && data.getAction().equals("inline-data")) { 91 | 92 | try { 93 | final String fileName = MD5.getMessageDigest(DateFormat.format("yyyy-MM-dd-HH-mm-ss", System.currentTimeMillis()).toString().getBytes()) + PHOTO_DEFAULT_EXT; 94 | filePath = dir + fileName; 95 | 96 | final Bitmap bitmap = (Bitmap) data.getExtras().get("data"); 97 | final File file = new File(filePath); 98 | if (!file.exists()) { 99 | file.createNewFile(); 100 | } 101 | 102 | BufferedOutputStream out; 103 | out = new BufferedOutputStream(new FileOutputStream(file)); 104 | final int cQuality = 100; 105 | bitmap.compress(Bitmap.CompressFormat.PNG, cQuality, out); 106 | out.close(); 107 | Log.d(TAG, "photo image from data, path:" + filePath); 108 | 109 | } catch (final Exception e) { 110 | e.printStackTrace(); 111 | } 112 | 113 | } else { 114 | if (cu != null) { 115 | cu.close(); 116 | cu = null; 117 | } 118 | Log.e(TAG, "resolve photo from intent failed"); 119 | return null; 120 | } 121 | if (cu != null) { 122 | cu.close(); 123 | cu = null; 124 | } 125 | return filePath; 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/uikit/MMAlert.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux.uikit; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.sourceforge.simcpux.R; 7 | import net.sourceforge.simcpux.Util; 8 | 9 | import android.app.Activity; 10 | import android.app.AlertDialog; 11 | import android.app.Dialog; 12 | import android.app.ProgressDialog; 13 | import android.app.AlertDialog.Builder; 14 | import android.content.Context; 15 | import android.content.DialogInterface; 16 | import android.content.DialogInterface.OnCancelListener; 17 | import android.view.Gravity; 18 | import android.view.LayoutInflater; 19 | import android.view.View; 20 | import android.view.ViewGroup; 21 | import android.view.Window; 22 | import android.view.WindowManager; 23 | import android.webkit.WebView; 24 | import android.webkit.WebViewClient; 25 | import android.widget.AdapterView; 26 | import android.widget.BaseAdapter; 27 | import android.widget.LinearLayout; 28 | import android.widget.ListView; 29 | import android.widget.TextView; 30 | import android.widget.AdapterView.OnItemClickListener; 31 | 32 | public final class MMAlert { 33 | 34 | public interface OnAlertSelectId { 35 | void onClick(int whichButton); 36 | } 37 | 38 | private MMAlert() { 39 | 40 | } 41 | 42 | public static AlertDialog showAlert(final Context context, final String msg, final String title) { 43 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 44 | return null; 45 | } 46 | 47 | final Builder builder = new AlertDialog.Builder(context); 48 | builder.setIcon(R.drawable.ic_dialog_alert); 49 | builder.setTitle(title); 50 | builder.setMessage(msg); 51 | builder.setPositiveButton(R.string.app_ok, new DialogInterface.OnClickListener() { 52 | 53 | @Override 54 | public void onClick(final DialogInterface dialog, final int which) { 55 | dialog.cancel(); 56 | } 57 | }); 58 | final AlertDialog alert = builder.create(); 59 | alert.show(); 60 | return alert; 61 | } 62 | 63 | public static AlertDialog showAlert(final Context context, final int msgId, final int titleId) { 64 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 65 | return null; 66 | } 67 | 68 | final Builder builder = new AlertDialog.Builder(context); 69 | builder.setIcon(R.drawable.ic_dialog_alert); 70 | builder.setTitle(titleId); 71 | builder.setMessage(msgId); 72 | builder.setPositiveButton(R.string.app_ok, new DialogInterface.OnClickListener() { 73 | 74 | @Override 75 | public void onClick(final DialogInterface dialog, final int which) { 76 | dialog.cancel(); 77 | } 78 | }); 79 | final AlertDialog alert = builder.create(); 80 | alert.show(); 81 | return alert; 82 | } 83 | 84 | public static AlertDialog showAlert(final Context context, final int msgId, final int titleId, final DialogInterface.OnClickListener l) { 85 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 86 | return null; 87 | } 88 | 89 | final Builder builder = new AlertDialog.Builder(context); 90 | builder.setIcon(R.drawable.ic_dialog_alert); 91 | builder.setTitle(titleId); 92 | builder.setMessage(msgId); 93 | builder.setPositiveButton(R.string.app_ok, l); 94 | // builder.setCancelable(false); 95 | final AlertDialog alert = builder.create(); 96 | alert.show(); 97 | return alert; 98 | } 99 | 100 | public static AlertDialog showAlert(final Context context, final String msg, final String title, final DialogInterface.OnClickListener l) { 101 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 102 | return null; 103 | } 104 | 105 | final Builder builder = new AlertDialog.Builder(context); 106 | builder.setIcon(R.drawable.ic_dialog_alert); 107 | builder.setTitle(title); 108 | builder.setMessage(msg); 109 | builder.setPositiveButton(R.string.app_ok, l); 110 | // builder.setCancelable(false); 111 | final AlertDialog alert = builder.create(); 112 | alert.show(); 113 | return alert; 114 | } 115 | 116 | public static AlertDialog showAlert(final Context context, final int msgId, final int titleId, final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel) { 117 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 118 | return null; 119 | } 120 | 121 | final Builder builder = new AlertDialog.Builder(context); 122 | builder.setIcon(R.drawable.ic_dialog_alert); 123 | builder.setTitle(titleId); 124 | builder.setMessage(msgId); 125 | builder.setPositiveButton(R.string.app_ok, lOk); 126 | builder.setNegativeButton(R.string.app_cancel, lCancel); 127 | // builder.setCancelable(false); 128 | final AlertDialog alert = builder.create(); 129 | alert.show(); 130 | return alert; 131 | } 132 | 133 | public static AlertDialog showAlert(final Context context, final int msg, final int title, final int yes, final int no, final DialogInterface.OnClickListener lOk, 134 | final DialogInterface.OnClickListener lCancel) { 135 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 136 | return null; 137 | } 138 | 139 | final Builder builder = new AlertDialog.Builder(context); 140 | builder.setIcon(R.drawable.ic_dialog_alert); 141 | builder.setTitle(title); 142 | builder.setMessage(msg); 143 | builder.setPositiveButton(yes, lOk); 144 | builder.setNegativeButton(no, lCancel); 145 | // builder.setCancelable(false); 146 | final AlertDialog alert = builder.create(); 147 | alert.show(); 148 | return alert; 149 | } 150 | 151 | public static AlertDialog showAlert(final Context context, final String msg, final String title, final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel) { 152 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 153 | return null; 154 | } 155 | 156 | final Builder builder = new AlertDialog.Builder(context); 157 | builder.setIcon(R.drawable.ic_dialog_alert); 158 | builder.setTitle(title); 159 | builder.setMessage(msg); 160 | builder.setPositiveButton(R.string.app_ok, lOk); 161 | builder.setNegativeButton(R.string.app_cancel, lCancel); 162 | // builder.setCancelable(false); 163 | final AlertDialog alert = builder.create(); 164 | alert.show(); 165 | return alert; 166 | } 167 | 168 | public static AlertDialog showAlert(final Context context, final String msg, final String title, final String yes, final String no, final DialogInterface.OnClickListener lOk, 169 | final DialogInterface.OnClickListener lCancel) { 170 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 171 | return null; 172 | } 173 | 174 | final Builder builder = new AlertDialog.Builder(context); 175 | builder.setIcon(R.drawable.ic_dialog_alert); 176 | builder.setTitle(title); 177 | builder.setMessage(msg); 178 | builder.setPositiveButton(yes, lOk); 179 | builder.setNegativeButton(no, lCancel); 180 | // builder.setCancelable(false); 181 | final AlertDialog alert = builder.create(); 182 | alert.show(); 183 | return alert; 184 | } 185 | 186 | public static AlertDialog showAlert(final Context context, final String title, final View view, final DialogInterface.OnClickListener lOk) { 187 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 188 | return null; 189 | } 190 | 191 | final Builder builder = new AlertDialog.Builder(context); 192 | builder.setTitle(title); 193 | builder.setView(view); 194 | builder.setPositiveButton(R.string.app_ok, lOk); 195 | // builder.setCancelable(true); 196 | final AlertDialog alert = builder.create(); 197 | alert.show(); 198 | return alert; 199 | } 200 | 201 | public static AlertDialog showAlert(final Context context, final String title, final View view, final String ok, final String cancel, final DialogInterface.OnClickListener lOk, 202 | final DialogInterface.OnClickListener lCancel) { 203 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 204 | return null; 205 | } 206 | 207 | final Builder builder = new AlertDialog.Builder(context); 208 | builder.setTitle(title); 209 | builder.setView(view); 210 | builder.setPositiveButton(ok, lOk); 211 | builder.setNegativeButton(cancel, lCancel); 212 | // builder.setCancelable(false); 213 | final AlertDialog alert = builder.create(); 214 | alert.show(); 215 | return alert; 216 | } 217 | 218 | public static AlertDialog showAlert(final Context context, final String title, final String ok, final View view, final DialogInterface.OnClickListener lOk) { 219 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 220 | return null; 221 | } 222 | 223 | final Builder builder = new AlertDialog.Builder(context); 224 | builder.setTitle(title); 225 | builder.setView(view); 226 | builder.setPositiveButton(ok, lOk); 227 | // builder.setCancelable(true); 228 | final AlertDialog alert = builder.create(); 229 | alert.show(); 230 | return alert; 231 | } 232 | 233 | public static AlertDialog showAlert(final Context context, final String title, final String msg, final View view, final DialogInterface.OnClickListener lOk, 234 | final DialogInterface.OnClickListener lCancel) { 235 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 236 | return null; 237 | } 238 | 239 | final Builder builder = new AlertDialog.Builder(context); 240 | builder.setTitle(title); 241 | builder.setMessage(msg); 242 | builder.setView(view); 243 | builder.setPositiveButton(R.string.app_ok, lOk); 244 | builder.setNegativeButton(R.string.app_cancel, lCancel); 245 | // builder.setCancelable(true); 246 | builder.setOnCancelListener(new DialogInterface.OnCancelListener() { 247 | 248 | @Override 249 | public void onCancel(DialogInterface dialog) { 250 | if (lCancel != null) { 251 | lCancel.onClick(dialog, 0); 252 | } 253 | } 254 | }); 255 | final AlertDialog alert = builder.create(); 256 | alert.show(); 257 | return alert; 258 | } 259 | 260 | public static AlertDialog showAlert(final Context context, final String title, final View view, final DialogInterface.OnCancelListener lCancel) { 261 | if (context instanceof Activity && ((Activity) context).isFinishing()) { 262 | return null; 263 | } 264 | 265 | final Builder builder = new AlertDialog.Builder(context); 266 | builder.setTitle(title); 267 | builder.setView(view); 268 | // builder.setCancelable(true); 269 | builder.setOnCancelListener(lCancel); 270 | final AlertDialog alert = builder.create(); 271 | alert.show(); 272 | return alert; 273 | } 274 | 275 | public static Dialog showAlert(final Context context, final String title, final String[] items, String exit, final OnAlertSelectId alertDo) { 276 | return showAlert(context, title, items, exit, alertDo, null); 277 | } 278 | 279 | public static ProgressDialog showProgressDlg(final Context context, final String title, final String message, final boolean indeterminate, final boolean cancelable, final OnCancelListener lCancel) { 280 | 281 | return ProgressDialog.show(context, title, message, indeterminate, cancelable, new DialogInterface.OnCancelListener() { 282 | 283 | @Override 284 | public void onCancel(final DialogInterface dialog) { 285 | if (lCancel != null) { 286 | lCancel.onCancel(dialog); 287 | } 288 | } 289 | }); 290 | } 291 | 292 | public static AlertDialog showWebAlert(final Context context, final String title, final String rawUrl, final WebViewClient client, final DialogInterface.OnClickListener lOk, 293 | final DialogInterface.OnDismissListener lDismiss) { 294 | final View view = View.inflate(context, R.layout.webalert, null); 295 | final AlertDialog alert = showAlert(context, title, view, lOk); 296 | alert.setOnDismissListener(new DialogInterface.OnDismissListener() { 297 | 298 | @Override 299 | public void onDismiss(DialogInterface dialog) { 300 | 301 | if (lDismiss != null) { 302 | lDismiss.onDismiss(dialog); 303 | } 304 | } 305 | }); 306 | final WebView info = (WebView) view.findViewById(R.id.info_wv); 307 | info.loadUrl(rawUrl); 308 | if (client != null) { 309 | info.setWebViewClient(client); 310 | } 311 | return alert; 312 | } 313 | 314 | public static AlertDialog showWebAlert(final Context context, final String title, final String rawUrl, final WebViewClient client, final String ok, final String cancel, 315 | final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel, final DialogInterface.OnDismissListener lDismiss) { 316 | final View view = View.inflate(context, R.layout.webalert, null); 317 | final AlertDialog alert = showAlert(context, title, view, ok, cancel, lOk, lCancel); 318 | alert.setOnDismissListener(new DialogInterface.OnDismissListener() { 319 | 320 | @Override 321 | public void onDismiss(DialogInterface dialog) { 322 | if (lDismiss != null) { 323 | lDismiss.onDismiss(dialog); 324 | } 325 | } 326 | }); 327 | 328 | final WebView info = (WebView) view.findViewById(R.id.info_wv); 329 | info.loadUrl(rawUrl); 330 | if (client != null) { 331 | info.setWebViewClient(client); 332 | } 333 | return alert; 334 | } 335 | 336 | /** 337 | * @param context 338 | * Context. 339 | * @param title 340 | * The title of this AlertDialog can be null . 341 | * @param items 342 | * button name list. 343 | * @param alertDo 344 | * methods call Id:Button + cancel_Button. 345 | * @param exit 346 | * Name can be null.It will be Red Color 347 | * @return A AlertDialog 348 | */ 349 | public static Dialog showAlert(final Context context, final String title, final String[] items, String exit, final OnAlertSelectId alertDo, OnCancelListener cancelListener) { 350 | String cancel = context.getString(R.string.app_cancel); 351 | final Dialog dlg = new Dialog(context, R.style.MMTheme_DataSheet); 352 | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 353 | LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.alert_dialog_menu_layout, null); 354 | final int cFullFillWidth = 10000; 355 | layout.setMinimumWidth(cFullFillWidth); 356 | final ListView list = (ListView) layout.findViewById(R.id.content_list); 357 | AlertAdapter adapter = new AlertAdapter(context, title, items, exit, cancel); 358 | list.setAdapter(adapter); 359 | list.setDividerHeight(0); 360 | 361 | list.setOnItemClickListener(new OnItemClickListener() { 362 | 363 | @Override 364 | public void onItemClick(AdapterView parent, View view, int position, long id) { 365 | if (!(title == null || title.equals("")) && position - 1 >= 0) { 366 | alertDo.onClick(position - 1); 367 | dlg.dismiss(); 368 | list.requestFocus(); 369 | } else { 370 | alertDo.onClick(position); 371 | dlg.dismiss(); 372 | list.requestFocus(); 373 | } 374 | 375 | } 376 | }); 377 | // set a large value put it in bottom 378 | Window w = dlg.getWindow(); 379 | WindowManager.LayoutParams lp = w.getAttributes(); 380 | lp.x = 0; 381 | final int cMakeBottom = -1000; 382 | lp.y = cMakeBottom; 383 | lp.gravity = Gravity.BOTTOM; 384 | dlg.onWindowAttributesChanged(lp); 385 | dlg.setCanceledOnTouchOutside(true); 386 | if (cancelListener != null) { 387 | dlg.setOnCancelListener(cancelListener); 388 | } 389 | dlg.setContentView(layout); 390 | dlg.show(); 391 | return dlg; 392 | } 393 | 394 | } 395 | 396 | class AlertAdapter extends BaseAdapter { 397 | // private static final String TAG = "AlertAdapter"; 398 | public static final int TYPE_BUTTON = 0; 399 | public static final int TYPE_TITLE = 1; 400 | public static final int TYPE_EXIT = 2; 401 | public static final int TYPE_CANCEL = 3; 402 | private List items; 403 | private int[] types; 404 | // private boolean isSpecial = false; 405 | private boolean isTitle = false; 406 | // private boolean isExit = false; 407 | private Context context; 408 | 409 | public AlertAdapter(Context context, String title, String[] items, String exit, String cancel) { 410 | if (items == null || items.length == 0) { 411 | this.items = new ArrayList(); 412 | } else { 413 | this.items = Util.stringsToList(items); 414 | } 415 | this.types = new int[this.items.size() + 3]; 416 | this.context = context; 417 | if (title != null && !title.equals("")) { 418 | types[0] = TYPE_TITLE; 419 | this.isTitle = true; 420 | this.items.add(0, title); 421 | } 422 | 423 | if (exit != null && !exit.equals("")) { 424 | // this.isExit = true; 425 | types[this.items.size()] = TYPE_EXIT; 426 | this.items.add(exit); 427 | } 428 | 429 | if (cancel != null && !cancel.equals("")) { 430 | // this.isSpecial = true; 431 | types[this.items.size()] = TYPE_CANCEL; 432 | this.items.add(cancel); 433 | } 434 | } 435 | 436 | @Override 437 | public int getCount() { 438 | return items.size(); 439 | } 440 | 441 | @Override 442 | public Object getItem(int position) { 443 | return items.get(position); 444 | } 445 | 446 | @Override 447 | public long getItemId(int position) { 448 | return 0; 449 | } 450 | 451 | @Override 452 | public boolean isEnabled(int position) { 453 | if (position == 0 && isTitle) { 454 | return false; 455 | } else { 456 | return super.isEnabled(position); 457 | } 458 | } 459 | 460 | @Override 461 | public View getView(int position, View convertView, ViewGroup parent) { 462 | final String textString = (String) getItem(position); 463 | ViewHolder holder; 464 | int type = types[position]; 465 | if (convertView == null || ((ViewHolder) convertView.getTag()).type != type) { 466 | holder = new ViewHolder(); 467 | if (type == TYPE_CANCEL) { 468 | convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_cancel, null); 469 | } else if (type == TYPE_BUTTON) { 470 | convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout, null); 471 | } else if (type == TYPE_TITLE) { 472 | convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_title, null); 473 | } else if (type == TYPE_EXIT) { 474 | convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_special, null); 475 | } 476 | 477 | // holder.view = (LinearLayout) convertView.findViewById(R.id.popup_layout); 478 | holder.text = (TextView) convertView.findViewById(R.id.popup_text); 479 | holder.type = type; 480 | 481 | convertView.setTag(holder); 482 | } else { 483 | holder = (ViewHolder) convertView.getTag(); 484 | } 485 | 486 | holder.text.setText(textString); 487 | return convertView; 488 | } 489 | 490 | static class ViewHolder { 491 | // LinearLayout view; 492 | TextView text; 493 | int type; 494 | } 495 | } 496 | -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/wxapi/WXEntryActivity.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux.wxapi; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.Toast; 9 | 10 | import com.tencent.mm.opensdk.constants.ConstantsAPI; 11 | import com.tencent.mm.opensdk.modelbase.BaseReq; 12 | import com.tencent.mm.opensdk.modelbase.BaseResp; 13 | import com.tencent.mm.opensdk.modelmsg.SendAuth; 14 | import com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX; 15 | import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject; 16 | import com.tencent.mm.opensdk.modelmsg.WXMediaMessage; 17 | import com.tencent.mm.opensdk.openapi.IWXAPI; 18 | import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler; 19 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 20 | 21 | import net.sourceforge.simcpux.AddFavoriteToWXActivity; 22 | import net.sourceforge.simcpux.Constants; 23 | import net.sourceforge.simcpux.GetFromWXActivity; 24 | import net.sourceforge.simcpux.PayActivity; 25 | import net.sourceforge.simcpux.R; 26 | import net.sourceforge.simcpux.SendToWXActivity; 27 | import net.sourceforge.simcpux.ShowFromWXActivity; 28 | 29 | public class WXEntryActivity extends Activity implements IWXAPIEventHandler { 30 | 31 | private static final int TIMELINE_SUPPORTED_VERSION = 0x21020001; 32 | 33 | private Button gotoBtn, regBtn, launchBtn, checkBtn, payBtn, favButton; 34 | 35 | // IWXAPI 是第三方app和微信通信的openapi接口 36 | private IWXAPI api; 37 | 38 | @Override 39 | public void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.entry); 42 | 43 | // 通过WXAPIFactory工厂,获取IWXAPI的实例 44 | api = WXAPIFactory.createWXAPI(this, Constants.APP_ID, false); 45 | 46 | regBtn = (Button) findViewById(R.id.reg_btn); 47 | regBtn.setOnClickListener(new View.OnClickListener() { 48 | 49 | @Override 50 | public void onClick(View v) { 51 | // 将该app注册到微信 52 | api.registerApp(Constants.APP_ID); 53 | } 54 | }); 55 | 56 | gotoBtn = (Button) findViewById(R.id.goto_send_btn); 57 | gotoBtn.setOnClickListener(new View.OnClickListener() { 58 | 59 | @Override 60 | public void onClick(View v) { 61 | startActivity(new Intent(WXEntryActivity.this, SendToWXActivity.class)); 62 | finish(); 63 | } 64 | }); 65 | 66 | launchBtn = (Button) findViewById(R.id.launch_wx_btn); 67 | launchBtn.setOnClickListener(new View.OnClickListener() { 68 | 69 | @Override 70 | public void onClick(View v) { 71 | Toast.makeText(WXEntryActivity.this, "launch result = " + api.openWXApp(), Toast.LENGTH_LONG).show(); 72 | } 73 | }); 74 | 75 | checkBtn = (Button) findViewById(R.id.check_timeline_supported_btn); 76 | checkBtn.setOnClickListener(new View.OnClickListener() { 77 | 78 | @Override 79 | public void onClick(View v) { 80 | int wxSdkVersion = api.getWXAppSupportAPI(); 81 | if (wxSdkVersion >= TIMELINE_SUPPORTED_VERSION) { 82 | Toast.makeText(WXEntryActivity.this, "wxSdkVersion = " + Integer.toHexString(wxSdkVersion) + "\ntimeline supported", Toast.LENGTH_LONG).show(); 83 | } else { 84 | Toast.makeText(WXEntryActivity.this, "wxSdkVersion = " + Integer.toHexString(wxSdkVersion) + "\ntimeline not supported", Toast.LENGTH_LONG).show(); 85 | } 86 | } 87 | }); 88 | 89 | payBtn = (Button) findViewById(R.id.goto_pay_btn); 90 | payBtn.setOnClickListener(new View.OnClickListener() { 91 | 92 | @Override 93 | public void onClick(View v) { 94 | startActivity(new Intent(WXEntryActivity.this, PayActivity.class)); 95 | finish(); 96 | } 97 | }); 98 | 99 | favButton = (Button) findViewById(R.id.goto_fav_btn); 100 | favButton.setOnClickListener(new View.OnClickListener() { 101 | 102 | @Override 103 | public void onClick(View v) { 104 | startActivity(new Intent(WXEntryActivity.this, AddFavoriteToWXActivity.class)); 105 | finish(); 106 | } 107 | }); 108 | 109 | // debug 110 | 111 | // debug end 112 | 113 | api.handleIntent(getIntent(), this); 114 | } 115 | 116 | @Override 117 | protected void onNewIntent(Intent intent) { 118 | super.onNewIntent(intent); 119 | 120 | setIntent(intent); 121 | api.handleIntent(intent, this); 122 | } 123 | 124 | // 微信发送请求到第三方应用时,会回调到该方法 125 | @Override 126 | public void onReq(BaseReq req) { 127 | Toast.makeText(this, "openid = " + req.openId, Toast.LENGTH_SHORT).show(); 128 | 129 | switch (req.getType()) { 130 | case ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX: 131 | goToGetMsg(); 132 | break; 133 | case ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX: 134 | goToShowMsg((ShowMessageFromWX.Req) req); 135 | break; 136 | case ConstantsAPI.COMMAND_LAUNCH_BY_WX: 137 | Toast.makeText(this, R.string.launch_from_wx, Toast.LENGTH_SHORT).show(); 138 | break; 139 | default: 140 | break; 141 | } 142 | } 143 | 144 | // 第三方应用发送到微信的请求处理后的响应结果,会回调到该方法 145 | @Override 146 | public void onResp(BaseResp resp) { 147 | Toast.makeText(this, "openid = " + resp.openId, Toast.LENGTH_SHORT).show(); 148 | 149 | if (resp.getType() == ConstantsAPI.COMMAND_SENDAUTH) { 150 | Toast.makeText(this, "code = " + ((SendAuth.Resp) resp).code, Toast.LENGTH_SHORT).show(); 151 | } 152 | 153 | int result = 0; 154 | 155 | switch (resp.errCode) { 156 | case BaseResp.ErrCode.ERR_OK: 157 | result = R.string.errcode_success; 158 | break; 159 | case BaseResp.ErrCode.ERR_USER_CANCEL: 160 | result = R.string.errcode_cancel; 161 | break; 162 | case BaseResp.ErrCode.ERR_AUTH_DENIED: 163 | result = R.string.errcode_deny; 164 | break; 165 | default: 166 | result = R.string.errcode_unknown; 167 | break; 168 | } 169 | 170 | Toast.makeText(this, result, Toast.LENGTH_LONG).show(); 171 | } 172 | 173 | private void goToGetMsg() { 174 | Intent intent = new Intent(this, GetFromWXActivity.class); 175 | intent.putExtras(getIntent()); 176 | startActivity(intent); 177 | finish(); 178 | } 179 | 180 | private void goToShowMsg(ShowMessageFromWX.Req showReq) { 181 | WXMediaMessage wxMsg = showReq.message; 182 | WXAppExtendObject obj = (WXAppExtendObject) wxMsg.mediaObject; 183 | 184 | StringBuffer msg = new StringBuffer(); // 组织一个待显示的消息内容 185 | msg.append("description: "); 186 | msg.append(wxMsg.description); 187 | msg.append("\n"); 188 | msg.append("extInfo: "); 189 | msg.append(obj.extInfo); 190 | msg.append("\n"); 191 | msg.append("filePath: "); 192 | msg.append(obj.filePath); 193 | 194 | Intent intent = new Intent(this, ShowFromWXActivity.class); 195 | intent.putExtra(Constants.ShowMsgActivity.STitle, wxMsg.title); 196 | intent.putExtra(Constants.ShowMsgActivity.SMessage, msg.toString()); 197 | intent.putExtra(Constants.ShowMsgActivity.BAThumbData, wxMsg.thumbData); 198 | startActivity(intent); 199 | finish(); 200 | } 201 | } -------------------------------------------------------------------------------- /app/src/main/java/net/sourceforge/simcpux/wxapi/WXPayEntryActivity.java: -------------------------------------------------------------------------------- 1 | package net.sourceforge.simcpux.wxapi; 2 | 3 | 4 | import android.app.Activity; 5 | import android.app.AlertDialog; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.util.Log; 9 | 10 | import com.tencent.mm.opensdk.constants.ConstantsAPI; 11 | import com.tencent.mm.opensdk.modelbase.BaseReq; 12 | import com.tencent.mm.opensdk.modelbase.BaseResp; 13 | import com.tencent.mm.opensdk.openapi.IWXAPI; 14 | import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler; 15 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 16 | 17 | import net.sourceforge.simcpux.Constants; 18 | import net.sourceforge.simcpux.R; 19 | 20 | public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler { 21 | 22 | private static final String TAG = "WXPayEntryActivity"; 23 | 24 | private IWXAPI api; 25 | 26 | @Override 27 | public void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.pay_result); 30 | 31 | api = WXAPIFactory.createWXAPI(this, Constants.APP_ID); 32 | api.handleIntent(getIntent(), this); 33 | } 34 | 35 | @Override 36 | protected void onNewIntent(Intent intent) { 37 | super.onNewIntent(intent); 38 | setIntent(intent); 39 | api.handleIntent(intent, this); 40 | } 41 | 42 | @Override 43 | public void onReq(BaseReq req) { 44 | } 45 | 46 | @Override 47 | public void onResp(BaseResp resp) { 48 | Log.d(TAG, "onPayFinish, errCode = " + resp.errCode); 49 | 50 | if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) { 51 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 52 | builder.setTitle(R.string.app_tip); 53 | builder.setMessage(getString(R.string.pay_result_callback_msg, String.valueOf(resp.errCode))); 54 | builder.show(); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/push_up_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_actbtn_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_btn_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 10 | 13 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_choice_text_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 10 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_hyper_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_list_textcolor_one.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_list_textcolor_time.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 12 | 15 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_list_textcolor_two.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 12 | 15 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_pref_summary.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_pref_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_style_one_btn_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_style_two_btn_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/color/mm_title_btn_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 10 | 13 | 16 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_check_off_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_check_off_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_check_off_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_check_off_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_check_on_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_check_on_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_check_on_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_check_on_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_alert_dialog_background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_alert_dialog_background.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_alert_dialog_button_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_alert_dialog_button_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_alert_dialog_button_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_alert_dialog_button_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_alert_dialog_cancel_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_alert_dialog_cancel_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_alert_dialog_special_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_alert_dialog_special_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_alert_dialog_special_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_alert_dialog_special_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_one_disabled.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_one_disabled.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_one_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_one_focused.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_one_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_one_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/btn_style_one_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/btn_style_one_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_dialog_alert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_dialog_alert.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_dialog_long_click.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_dialog_long_click.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_first_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_first_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_first_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_first_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_last_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_last_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_last_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_last_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_one_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_one_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_one_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_one_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_single_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_single_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_single_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_single_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_top_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_top_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_preference_top_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/ic_preference_top_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_checkbox_mini_checked.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_checkbox_mini_checked.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_checkbox_mini_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_checkbox_mini_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_edit_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_edit_focused.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_edit_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_edit_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_listitem_disable.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_listitem_disable.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_listitem_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_listitem_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_listitem_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_listitem_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_submenu_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_submenu_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_submenu_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_submenu_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_act_btn_disable.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_act_btn_disable.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_act_btn_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_act_btn_focused.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_act_btn_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_act_btn_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_act_btn_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_act_btn_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_back_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_back_focused.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_back_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_back_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_back_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_back_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_bg.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_btn_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_btn_focused.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_btn_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_btn_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_title_btn_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_title_btn_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mm_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/mm_trans.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/send_img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/send_img.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/send_music_thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/send_music_thumb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/send_music_thumb_backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-hdpi/send_music_thumb_backup.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fyc/WeChatSDK_sample_Android/a18ba3f00796cbc3e86591a9c81ba3c8bfb7965b/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_style_alert_dialog_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_style_alert_dialog_cancel.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_style_alert_dialog_special.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_style_one.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_selector_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 13 | 14 | 17 | 18 | 22 | 27 | 31 | 32 | 36 | 40 | 41 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mm_checkbox_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 12 | 16 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mm_checkbox_mini.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mm_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mm_submenu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 10 | 13 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mm_title_btn_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/mm_title_btn_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 10 | 13 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/preference_first_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/preference_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/preference_last_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/preference_one_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_fav_to_wx.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 11 | 12 | 15 | 16 | 21 | 22 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_example_ui.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_catalog.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_checkbox.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_child.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 9 | 12 | 13 | 14 | 15 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_content_choice.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_content_domainmail.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_content_domainmaillist.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 23 | 24 | 28 | 29 | 30 | 35 | 36 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_content_keyvalue.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 22 | 23 | 27 | 28 | 29 | 33 | 34 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_dialog_edittext.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_list_content.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_null.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | 18 | 19 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_self_vuser.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_submenu.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_preference_widget_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/mm_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 21 | 22 | 26 | 27 | 28 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/pay.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 |