我想更改应用程序风格的版本名称,但仅限于它是调试版本.
(例如,调试版本将具有类似1.0.1 D(DEBUG)555或1.0.1 P(DEBUG)555的版本,但是我希望版本构建仅具有1.0.1版本)我如何实现这一目标?
基本上我有这些构建类型:
buildTypes {
debug {
versionNameSuffix " (DEBUG) " + mBuild
}
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), file('proguard-project.txt')
signingConfig signingConfigs.release
}
}
Run Code Online (Sandbox Code Playgroud)
和这些口味(针对不同的api环境):
productFlavors {
dev {
versionName = android.defaultConfig.versionName + " D"
}
prod {
versionName = android.defaultConfig.versionName + " P"
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法如何在没有产品风格版本名称更改的情况下进行发布版本?
我试图通过动态设置版本名称
buildTypes.each { buildType ->
if(buildType.name == 'debug') {
productFlavors.dev.versionName = android.defaultConfig.versionName + " D"
}
}
Run Code Online (Sandbox Code Playgroud)
但这会导致
无法在GroupableProductFlavorDsl容器上找到属性"dev".
我正在制作一个Image加载器,用于将图像加载到列表中 - 所以为了使它平滑,除了将图像设置为视图外,所有内容都需要在后台线程中运行.问题是代码中的Runnable有时不会被执行.我从后台线程调用setImage方法.
protected void setImage(final ImageView img, final Bitmap bm, String hash) {
img.setTag(TAG_RESPONSE, hash);
Log.v(TAG, "setting image bitmap1");
//TODO: here is the bug - sometimes the runnable below is not called
img.post(new Runnable() {
@Override
public void run() {
Log.v(TAG, "setting image bitmap2");
img.setImageBitmap(bm);
img.invalidate();
}
});
}
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法我做错了什么?
根据官方文档,NotificationCompat.Builder类应该有方法addAction,但我无法找到它(我得到"方法addAction(int,String,null)未定义类型NotificationCompat.Builder")
有没有人想出如何访问这种方法?
我已经配置了build.gradle,因此每次创建发布版本时它都会在version.properties中增加版本代码.我还使用apk文件的版本代码.然而Android工作室似乎忽略了版本更改所以当我从ide运行调试版本然后使用控制台组装版本构建(增加版本号)然后再次从IDE运行调试时,它正确地构建了一个带有增加版本的apk filename BUT将旧apk上传到设备.
因此,对于例如,我们有一个版本代码= 377.
我错过了什么?
这是我的gradle脚本:
ext{
versionPropFile = 'version.properties'
Properties versionProps = getVersionProps()
}
project.archivesBaseName=project.archivesBaseName+"-v"+versionProps['name'] + "(" + versionProps['code']+")"
def Properties getVersionProps(){
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(file(versionPropFile)))
return versionProps
}
task('increaseVersionCode') << {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(file(versionPropFile)))
int versionCode = versionProps['code'].toInteger()
versionProps['code'] = (versionCode+1)+""
versionProps.store(new FileOutputStream(file(versionPropFile)), "App …
Run Code Online (Sandbox Code Playgroud) 当我使用新的回收器视图时,我注意到滚动条不像常规ScrollView/ListView那样流畅.在适配器项目中滚动时,它似乎无法识别,但只有在新项目出现/旧项目消失时才会更改,因此进度条会跳转而不是平滑移动.这是一个展示此问题的视频.有没有办法使它顺利?
我的布局:
<android.support.v7.widget.RecyclerView
android:id="@+id/listRecycler"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)
分段:
mListRecycler.setAdapter(mAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mListRecycler.setLayoutManager(layoutManager);
Run Code Online (Sandbox Code Playgroud)
适配器:
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private List<News> items;
private int itemLayout;
public NewsAdapter(List<News> items, int itemLayout) {
this.items = items;
this.itemLayout = itemLayout;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(itemLayout, parent, false);
v.setOnClickListener(this);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
News item = items.get(position);
holder.text.setText(item.getTitle());
holder.itemView.setTag(item);
} …
Run Code Online (Sandbox Code Playgroud) 如何使通知按钮按预期显示(如下图中的第二个通知)?
这是我的代码:
Notification.Builder nb = new Notification.Builder(mCtx);
nb.setTicker("DATART");
nb.setSmallIcon(R.drawable.ic_menu_info_details_select);
nb.setContentText("DATART text");
nb.setContentTitle(mCtx.getString(R.string.app_name));
nb.setContentIntent(getClickIntent());
nb.setAutoCancel(true);
nb.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND);
nb.setLights(LED, LEDON, LEDOFF);
nb.addAction(android.R.drawable.ic_btn_speak_now, "Prihodit", PendingIntent.getActivity(mCtx, 0, new Intent(mCtx, AuctionProductDetail.class), 0));
nb.addAction(android.R.drawable.ic_dialog_map, "Mapa", PendingIntent.getActivity(mCtx, 0, new Intent(mCtx, AuctionProductDetail.class), 0));
return nb.build();
Run Code Online (Sandbox Code Playgroud)