上網查了不少資料,一直看到說使用getButton
但一直出錯顯示沒有getButton這方法,那時才意識到自己使用的不是AlertDialog 是 Dialog (自訂義 繼承AlertDialog.Builder)
上網查了不少資料,一直看到說使用getButton
但一直出錯顯示沒有getButton這方法,那時才意識到自己使用的不是AlertDialog 是 Dialog (自訂義 繼承AlertDialog.Builder)
官方:https://developers.google.com/maps/documentation/directions/intro?hl=zh-tw
我覺得不錯的:http://blog.csdn.net/mad1989/article/details/9734667
過去是用GCM 但firebase出來就有FCM
一直想要試試看FCM APP打訊息給APP,終於成功了!
之前自己架伺服器設webserverAPI,再讓Android去呼叫伺服器API
這次用Android內直接打fcm send,但這樣做法是不建議,因為金鑰暴露在外面...
後來想只是自己的小APP 玩玩而已就練練隨便寫
=============================================================================
compile 'com.squareup.okhttp3:okhttp:3.3.0'
============================================================================= public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
============================================================================= new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { OkHttpClient client = new OkHttpClient(); JSONObject json = new JSONObject(); JSONObject dataJson = new JSONObject(); dataJson.put("body", "Hi this is sent from device to device"); dataJson.put("title", "dummy title"); json.put("notification", dataJson); json.put("to", "暫時寫自己的TOKEN測試用"); RequestBody body = RequestBody.create(JSON, json.toString()); Request request = new Request.Builder() .header("Authorization", "key=AAAA0qHCG1g:APA91bEkkT.....JteHVBNbvc0h31xs3hAnq" ) .url("https://fcm.googleapis.com/fcm/send") .post(body) .build(); Response response = client.newCall(request).execute(); String finalResponse = response.body().string(); } catch (Exception e) { //Log.d(TAG,e+""); } return null; } @Override protected void onPostExecute( Void result) { } }.execute();
=============================================================================
注意:KEY是在
我個人常看到的
@Nullable
寫HttpClient的時候出現以下錯誤
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. >
http://maksim28.blogspot.tw/2013/01/android-timepicker.html
Intent intent = new Intent(MainActivity.this, AppleFragment.class); startActivity(intent);
進階可參考此篇[Andriod] 透過Intent轉換Activity