【发布时间】:2019-05-16 05:12:25
【问题描述】:
我正在设置动态通知声音,并想从 android 的扩展文件中设置。这可能吗?,如果是,那么我如何设置或访问扩展文件(.wav)到代码(通知生成器),请分享一些相同的代码
我的尝试:
FCM 代码:
val AUTHORITY = "com.example.provider.SampleZipFileProvider"
val CONTENT_URI = Uri.parse("content://$AUTHORITY")
val defaultSoundUri = Uri.parse("$CONTENT_URI/${appNotification.sound_name}")
val notificationBuilder = NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setContentTitle(getString(R.string.app_name))
.setStyle(NotificationCompat.BigTextStyle().bigText(appNotification.message))
.setWhen(0)
.setChannelId(Constants.NOTIFICATION_CHNANEL_ID)
.setContentText(appNotification.message.decodeUnicode())
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
SampleZipFileProvider.class
public class SampleZipFileProvider extends APEZProvider {
// main content provider URI
private static final String CONTENT_PREFIX = "content://";
// must match what is declared in the Zip content provider in
// the AndroidManifest.xml file
private static final String AUTHORITY = "com.example";
public static final Uri ASSET_URI = Uri.parse(CONTENT_PREFIX + AUTHORITY);
public String getAuthority() {
return AUTHORITY;
}
}
清单:
<provider android:name=".zipfile.SampleZipFileProvider"
android:authorities="com.example"
android:exported="false"
android:grantUriPermissions="true"
android:multiprocess="true">
<meta-data android:name="mainVersion"
android:value="1"/>
</provider>
【问题讨论】:
标签: android notifications android-notifications android-fileprovider apk-expansion-files