1、使用友盟分享有的界面可以,有的一直提示QQ和QQ空間一直提示圖片存儲(chǔ)錯(cuò)誤或沒(méi)有存儲(chǔ)權(quán)限,最后才發(fā)現(xiàn)失敗的地方是因?yàn)槭褂昧司W(wǎng)絡(luò)圖片地址,而這個(gè)地址又用不了了。
2、Hijson格式化后臺(tái)返回的json字符串,值為null時(shí),自動(dòng)去掉了,搞得有用的字段沒(méi)寫(xiě)到。
3、enum一般用來(lái)定義常量
4、友盟QQ和空間分享收不到回調(diào),需添加
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode,resultCode,data);
}
5、manifest中package和gradle中applicationID的區(qū)別
1、package主要用于指定類(lèi)和資源文件存放的位置。
2、applicationID是應(yīng)用的唯一標(biāo)識(shí)符,多渠道打包是可以為不同渠道配置不同的applicationID的,但這樣他們就不是同一個(gè)應(yīng)用了,更新也無(wú)法直接覆蓋安裝了。
如果兩個(gè)不一樣時(shí),第三方SDK需要我們的包名時(shí),要提供的是applicationID,這才是應(yīng)用標(biāo)識(shí)符。
6、org.gradle.jvmargs = -Xmx1536m 是Gradle 的默認(rèn)最大堆大小為 1536 MB,如果電腦很卡可以改小一點(diǎn)就像給studio分配內(nèi)存一樣。
7、在studio設(shè)置頁(yè)面設(shè)置代理將會(huì)使所有項(xiàng)目都生效,在gradle.properties中設(shè)置代理將會(huì)用于整個(gè)項(xiàng)目(在studio設(shè)置中設(shè)置代理會(huì)覆蓋gradle.properties中的設(shè)置),如果要單獨(dú)為某個(gè)module設(shè)置代理就寫(xiě)在模塊的gradle的android{里}
apply plugin: 'com.android.application'
android {
...
defaultConfig {
...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
}
...
}
8、Google和jcenter下載過(guò)慢可以使用阿里的地址(https://maven.aliyun.com/mvn/view),按下面的形式,要什么庫(kù)就引入
maven {url "http://maven.aliyun.com/nexus/content/groups/public/"}
也可以使用離線的配置,配置方法https://developer.android.google.cn/studio/intro/studio-config
9、project structure中可配置多渠道打包和為調(diào)試添加簽名,多變種等
10、發(fā)送消息到通知欄,更多設(shè)置可參考https://blog.csdn.net/weixin_45468359/article/details/107069306
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//適配8.0及以上需要設(shè)置NotificationChannel,且NotificationChannel的id與Notification的channelId必須相同
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "模擬驗(yàn)證碼", NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
}
Notification notification = new NotificationCompat.Builder(this, channelId)
.setContentTitle("登錄驗(yàn)證碼")
.setContentText("登錄驗(yàn)證碼是" + stringBuilder.toString())
.setSmallIcon(R.mipmap.ic_launcher)
.build();
notificationManager.notify(1, notification);