顯示具有 Android 標籤的文章。 顯示所有文章
顯示具有 Android 標籤的文章。 顯示所有文章

2022年3月15日 星期二

Android 分享功能

 

網路圖片
https://stickershop.line-scdn.net/stickershop/v1/sticker/438329029/android/sticker.png

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/jpg");
Uri u = Uri.fromFile(f);
intent.putExtra(Intent.EXTRA_STREAM, u);
}
}
intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
intent.putExtra(Intent.EXTRA_TEXT, msgText);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().startActivity(Intent.createChooser(intent, activityTitle));

Android 網路圖片轉Drawable

1.有一張網路圖片路徑
private void initAudio(){
new DownloadImageTask().execute(YouTubeUtil.getYoutubePic(youtubeId));
}
2. 透過異步下載
private class DownloadImageTask extends AsyncTask<String, Void, Drawable> {
protected Drawable doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
}

protected void onPostExecute(Drawable result) {
tracks.add(new Track("Track 0", "Artist 0", result));
// mImageView.setImageDrawable(result);
}
}

Android Drawable 轉 Bitmap

 


BitmapDrawable bd = (BitmapDrawable) track.getDrawable();
icon = bd.getBitmap();

2021年10月28日 星期四

Android Studio 聊天室下拉加載歷史訊息

 一開始需求是每次有新的訊息要在最下面

然後就很突然的,將 RecyclerView 設置為倒序

LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), 
LinearLayoutManager.VERTICAL, true); // 列表翻轉
linearLayoutManager.setStackFromEnd(true); // 列表在底部開始展示, 反轉後由上面開始展示
rvMessagesChat.setLayoutManager(linearLayoutManager);
rvMessagesChat.setHasFixedSize(true);
rvMessagesChat.setAnimation(null);


但是在加載新資料的時候,舊資料會被擠下去

int beforeSize = mList.size();
int afterSize = model.vModelRecord.size();
profileMessagesChatAdapter.addList(model.vModelRecord);
profileMessagesChatAdapter.notifyItemRangeInserted(beforeSize, afterSize);


所以需要新增這行,這樣就不會有擠壓的動畫

rvMessagesChat.setAnimation(null);

2021年8月25日 星期三

AppsFlyer 廣告追蹤

 Apps Flyer 是一個多平台整合的廣告追蹤網站


Apps Flyer 相關

Android SDK 集成

iOS SDK 集成


Facebook 相關

Facebook 廣告配置指南

Facebook SDK

Facebook Dashboard



iOS 14.5 官方將廣告追蹤透明化

必須經過用戶同意方可進行追蹤

再設定 Facebook 追蹤時,

必須將事件管理工具 > 資料來源 > 設定 > 為 SKAdNetwork 設定應用程式事件 開啟

並編輯事件,才可以收到來自 iOS 的資料


Swift 

AppEvents.logEvent(AppEvents.Name.completedRegistration)


Android Studio IDE 錯誤

 :app:compile xxxxx JavaWithJavac FAILED An exception has occurred in the compiler (1.8.0_312). Please file a bug against the Java compiler ...