这是我用按钮设置通知的代码.
Intent receiverIntent = new Intent(ctx, ResponsivePrefsActivity.class);
PendingIntent pReceiverIntent = PendingIntent.getActivity(ctx, 1, receiverIntent, 0);
Intent clearIntent = new Intent(ctx, ResponsivePrefsActivity.class);
clearIntent.setAction("clear");
PendingIntent pClearIntent = PendingIntent.getActivity(ctx, 1, clearIntent, 0);
Intent colorsIntent = new Intent(ctx, ResponsivePrefsActivity.class);
colorsIntent.setAction("colors");
PendingIntent pColorsIntent = PendingIntent.getActivity(ctx, 1, colorsIntent, 0);
Intent animationIntent = new Intent(ctx, ResponsivePrefsActivity.class);
animationIntent.setAction("animation");
PendingIntent pAnimation = PendingIntent.getActivity(ctx, 1, animationIntent, 0);
Notification.Builder builder;
builder = new Notification.Builder(ctx).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(false)
.setContentTitle("Draw Me: A Live Wallpaper").setContentText("Never get bored again!")
.setContentIntent(pReceiverIntent).addAction(R.raw.ic_menu_close_clear_cancel, "Clear", pClearIntent)
.addAction(R.raw.ic_menu_edit, "Colors", pColorsIntent).addAction(R.raw.ic_menu_play_clip, "Animation", pAnimation);
Notification notification …Run Code Online (Sandbox Code Playgroud) 我正在使用FileProvider从设备中获取照片.实现在调试版本中运行得很好(minifyEnabled false)但是当我构建版本构建(minifyEnabled为true)时,我收到一个错误:
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider:
java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider"
on path: DexPathList[[zip file "/data/app/com.package.name-2/base.apk"],
nativeLibraryDirectories=[/data/app/om.package.name-2/lib/arm, /vendor/lib, /system/lib]]
Run Code Online (Sandbox Code Playgroud)
所以我猜这与proguard设置有关
我有
compile 'com.android.support:support-v13:23.1.1'
Run Code Online (Sandbox Code Playgroud)
这是我的gradle文件中的v4的超集
minSdkVersion 21
targetSdkVersion 23
Run Code Online (Sandbox Code Playgroud)
和
-keep class android.support.v4.app.** { *; }
-keep class android.support.v4.content.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep interface android.support.v4.content.** { *; }
-keep class * extends android.content.ContentProvider
Run Code Online (Sandbox Code Playgroud)
在我的proguard-rules.pro文件中
我已经测试了Android 5和6,同样的事情发生了.任何建议都会有用,提前谢谢.