發表文章

JavaScript - Web 列印

<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>This is a Heading</h1> <p  onclick="printPage()">This is a paragraph.</p> <script> function printPage() {     var w = window.open();       var html = "<!DOCTYPE HTML>";     html += '<html>';     html += '<head><style></style></head>';       html += "<body onload='window.focus();window.print();window.close();'>";     html += "<img src='http://www.7-11.com.tw/event/16minions/img/minion1.png'/>";       html += "</body></html>";     w.document.write(html);     w.document.close(); }; </script> </body> </html>

Android - wechat share 微信分享

Intent: Intent intent = new Intent(); //選擇好友分享頁面 ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI"); intent.setComponent(comp); intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putExtra("Kdescription", "我在測試"); intent.setType("image/*"); //添加Uri圖片 ArrayList<Uri> imageUris = new ArrayList<Uri>(); imageUris.add(getScreenShotTop()); ntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); startActivity(intent); SDK: (compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:1.1.2')             //分享             String text = "測試分享文字";             // 初始化一个WXTextObject对象             WXTextObject textObj = new WXTextObject();             textObj.text = text;             // 用WXTextObject对象初始化...

Android - 分享至其他APP

調用分享窗: public static void shareMsg(Context context,String msgText,String imgPath) {                 Intent intent = new Intent(Intent.ACTION_SEND);                 if (imgPath == null || imgPath.equals("")) {                         intent.setType("text/plain"); // 纯文本                 } else {                         File f = new File(imgPath);                         if (f != null && f.exists() && f.isFile()) {                                 intent.setType("image/*");                               ...

Android - Bluetooth Multiple 藍芽一對多

Reference: http://developer.android.com/intl/zh-tw/guide/topics/connectivity/bluetooth.html Example: https://github.com/polyclef/BluetoothChatMulti File -> New -> Import Sample ->  Bluetooth Chat  Keyword: Bluetooth Chat Bluetooth Socket

Android - Linking to Your Products 開啟APP安裝頁面

Reference: http://developer.android.com/intl/zh-tw/distribute/tools/promote/linking.html Example: final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try {     startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) {     startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); }