發表文章

目前顯示的是 2017的文章

Android Studio - :app:processDebugManifest 宣告集中不允許內容

錯誤訊息 Error:Execution failed for task ':app:processDebugManifest'. > com.android.manifmerger.ManifestMerger2$MergeFailureException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 宣告集中不允許內容。 解決方法 build.gradle內的classpath 'com.android.tools.build:gradle:2.3.0'改為classpath 'com.android.tools.build:gradle:2.2.3'

Android - drawable圓角框線

1.在drawable資料夾下新增xml <?xml version="1.0" encoding="utf-8"?> <shape     xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="oval"     >     <!--     shape的類型含有:     1.rectangle - 長方形、矩形     2.oval - 橢圓形、卵形     3.line - 線     4.ring - 環形     -->     <!-- 圓角,Layout佈局圓角幅度設定值 -->     <corners         android:radius="15dp"         />     <!-- 框內底部顏色 -->     <solid         android:color="@color/dialog_button_dark"         />     <!-- padding內縮距離 -->     <padding         android:left="5dp"         android:right="5dp"         android:top="1dp"         android:bottom="1dp"         /> </shape>

Android - 換頁動畫

1.在Actitivy上達到換頁動畫 overridePendingTransition (下一頁進入動畫,本頁結束動畫); overridePendingTransition(R.anim.slide_left_in, R.anim.slide_right_out); PS: 需加在finish()或startActivity(intent)後面。 2.在Fragment上達到換頁動畫 FragmentTransaction ft = manager.beginTransaction(); ft. setCustomAnimations (R.anim.slide_in_left, R.anim.slide_out_right); ft.replace(R.id.realtabcontent, new Fragment1()); ft.addToBackStack(null); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commitAllowingStateLoss(); PS: 若不需要換頁動畫可設為overridePendingTransition(0, 0);及setCustomAnimations(0, 0);

Android - OkHttp3連線 post應用

引用:compile 'com.squareup.okhttp3:okhttp:3.8.1' 1.基本應用 public static final MediaType MEDIA_TYPE_MARKDOWN             = MediaType.parse("text/x-markdown; charset=utf-8"); public static final MediaType JSON         = MediaType.parse("application/json; charset=utf-8"); private static final String IMGUR_CLIENT_ID = "..."; private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/*"); private static final MediaType MEDIA_TYPE_VIDEO = MediaType.parse("video/*"); private static final OkHttpClient client = new OkHttpClient(); public static String queryJsonPost(String url, JSONObject jsonObj, Boolean hflag) {     String result = null;     Log.d("send_url", url);     String jsonObjStr = "";     try {         if (jsonObj != null) {             jsonObjStr = jsonObj.toString();         } else {             jsonObjStr = "";         }         Log.d("send

Android - TextView 點擊效果

1.方形點擊效果: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:text="文字" android:clickable="true" android:background="?attr/selectableItemBackground" /> 2.圓形點擊效果: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:text="文字" android:clickable="true" android:background="?attr/ selectableItemBackgroundBorderless " /> 3.點擊變換文字顏色: 3-1建顏色檔/res/color/text_color.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:color="#FFFFFF" /> <item android:state_focused="true" android:color=

Android - GCM推播注意

管理憑證: https://console.developers.google.com 1.先將資料庫內的Google Cloud Messaging啟用。 2.建立憑證  API * 1  注意:IPV4白名單 0.0.0.0/0 ,IPV6白名單 0::0/0 。  用戶端 * 1  注意 :SHA-1憑證指紋,debug和release版 不同 。

Android - 載圖Picasso、Imageloader

Picasso: https://github.com/square/picasso // 顯示圖片 Picasso.with(mContext)                 .load(url)                 .placeholder(R.mipmap.ic_launcher) //預設顯示                 .error(R.mipmap.ic_launcher) //錯誤顯示                 .fit() //顯示寬高為預設圖的寬高或是.resize(w, h)指定寬高                 .into(iv_photo); // 滑動載入優化 mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {       @Override       public void onScrollStateChanged(RecyclerView recyclerView, int newState) {            if (newState == RecyclerView.SCROLL_STATE_IDLE) {//滑动停止的時加載圖片                  Picasso.with(mActivity).resumeTag(mAdapter);             } else {//滑动时候不加載圖片                  Picasso.with(mActivity).pauseTag(mAdapter);            }      } }); Imageloader: https://github.com/nostra13/Android-Universal-Image-Loader protected ImageLoader imageLoader; // 須在Activity先設置(onCreate) ImageLoaderConfiguration config = new Imag

Android - 輸入字串排除 使用InputFilter

// 宣告輸入框 EditText et_name = (EditText) findViewById(R.id. et_name); 方法一:使用 isLetterOrDigit 方法排除大部分特殊符號 InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (!Character.isLetterOrDigit(source.charAt(i))) { return ""; } } return null; } }; et_name.setFilters(new InputFilter[] { filter }); 方法二:使用 Pattern 排除指定特殊符號 InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { String EXCLUDE_PATTERN = "[/。,、':∶;?‘’“”〝〞ˆˇ﹕︰﹔﹖﹑·¨….¸;!´?!~—ˉ|‖"〃`@﹫¡¿﹏﹋﹌︴々﹟#﹩$﹠&﹪%*﹡﹢﹦﹤‐ ̄¯―﹨ˆ˜﹍﹎+=<__-ˇ~﹉﹊()〈〉‹›﹛﹜『』〖〗[]《》〔〕{}「」【】︵︷︿︹︽_﹁﹃︻︶︸﹀︺︾ˉ﹂﹄︼❝❞!():,'\\[\\]{}^・.·.•#^*+=\<>&§⋯`-–/—|\"/\\\\]"; Pattern pattern = Pattern.compile(EXCLUDE_PATTERN); Matcher matcher =

cmd - openssl 查看網站憑證

查看憑證 openssl s_client -showcerts -connect URL:PORT

Android - Bitmap 處理

等比縮放 Bitmap bitmap = Bitmap.createScaledBitmap(bitmap                     , 500                     , 500                     , true             ); 設定X、Y裁切 Bitmap bitmap = Bitmap.createBitmap(bitmap                         , 0                         , 0                         , cropWidth   // 寬度                         , cropWidth  // 高度                         , vMatrix                         , true                 );

Android - git 使用

使用GIT做版本控制,為程式做備份, 達到協同合作開發便利性。 在MAC的環境下,使用工具如下 1.SourceTree 版本控制圖形化介面,可將程式碼上傳到 BitBucket 或 GitHub 空間 - http://www.sourcetreeapp.com/ 2.BitBucket 免費+私人空間不公開程式碼  - https://bitbucket.org/ *設置忽略不需要上傳的內容, 創建.gitignore的文件以 設定忽略 .DS_Store gradlew.bat *.iml local.properties .gradle .idea build

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对象初始化一个WXMediaMessage对象             WXMediaMessage msg = new WXMediaMessage();             msg.mediaObject = tex

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/*");                                 Uri u = Uri.fromFile(f);                                 intent.putExtra(Intent.EXTRA_STREAM, u);                         }                 }                 intent.putExtra(Intent.EXTRA_SUBJECT, "分享");                 intent.putExtra(Intent.EXTRA_TEXT, "我在用分享!");                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                 context.startActivity(Intent.createChooser(int