小编nic*_*ich的帖子

openjdk 平台二进制文件在构建 android 应用程序时使用了如此多的内存

当我构建 android 应用程序时,它可能需要 5 分钟到 15 分钟。如何解决内存问题。有没有办法减少内存消耗?如何让构建更快?

我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.xxx.xxx"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }) …
Run Code Online (Sandbox Code Playgroud)

java openjdk android android-gradle-plugin

6
推荐指数
2
解决办法
1万
查看次数

Kotlin - 通过 Intent 将函数作为参数传递

我在 kotlin 扩展文件中有这个函数来传递方法,但它不起作用。请向我解释它是如何正确制作的,我试试这个:

fun showErrorClientScreen(context: Context, action : () -> Unit) {
    val intent = Intent(context, RestClientErrorActivity::class.java)

    val bundle = Bundle()
    bundle.putSerializable(UPDATE_CLIENT_ERROR, ErrorClientListener {  action })
    intent.putExtra(UPDATE_CLIENT_ERROR_BUNDLE, bundle)

    context.startActivity(intent)
}
Run Code Online (Sandbox Code Playgroud)

使用java接口

public interface ErrorClientListener extends Serializable {

    void tryAgainFunction();

}
Run Code Online (Sandbox Code Playgroud)

以及我需要收听的活动单击按钮并再次尝试发送请求:

class RestClientErrorActivity: BaseActivity(), View.OnClickListener {

    private lateinit var errorClientListener: ErrorClientListener

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_rest_client_error)

        try {
            val bundle = intent.getBundleExtra(UPDATE_CLIENT_ERROR_BUNDLE)
            errorClientListener = bundle?.getSerializable(UPDATE_CLIENT_ERROR) as ErrorClientListener
        } catch (e: Exception) {
            e.message
        }
    }

    override fun onClick(v: …
Run Code Online (Sandbox Code Playgroud)

serialization android android-intent kotlin

6
推荐指数
1
解决办法
3639
查看次数

msg:fragments 不支持数据绑定表达式(在标签 <fragment> 中)数据绑定错误

当我尝试使用地图为标记片段添加可见性时,我遇到了数据绑定问题:

<layout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        >
    <data>
        <import type="android.view.View"/>
        <import type="xxx.xxx.MapContract.ViewModel"/>
        <variable
                name="vm"
                type="ViewModel"
                />
    </data>
    <FrameLayout
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            >
        <fragment
                android:id="@+id/map_fragment"
                class="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="@{vm.showMap}" // here problem
                />
Run Code Online (Sandbox Code Playgroud)

如何使用数据绑定解决这个问题?为什么片段不支持数据绑定?

data-binding android android-databinding

3
推荐指数
1
解决办法
1018
查看次数

无法编辑 50x50 像素以下的图像

当我尝试在桌面上设置壁纸时,我收到此消息。为什么?以及如何删除此消息?

在此处输入图片说明

我的代码:-当单击按钮时:

Intent intent = new Intent();                                                     
intent.setAction(Intent.ACTION_ATTACH_DATA);                                      
intent.addCategory(Intent.CATEGORY_DEFAULT);                                      
intent.setDataAndType(ContactsContract.Contacts.CONTENT_URI, "image/*");          
intent.putExtra("mimeType", "image/*");                                           
startActivityForResult(Intent.createChooser(intent, "Select service:"), position);
Run Code Online (Sandbox Code Playgroud)

然后onActivityResult:

@Override                                                                      
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);                     

    resultView.setDrawingCacheEnabled(true);                                   
    Bitmap bitmap = resultView.getDrawingCache();                              
    new TaskSetWallpaper(GalleryActivity.this).execute(bitmap);                
}                                                                              
Run Code Online (Sandbox Code Playgroud)

和设置壁纸的内部类:

public class TaskSetWallpaper extends AsyncTask<Bitmap, Void, Bitmap>                              
{                                                                                                  
    private Context context;                                                                       
    private ProgressDialog pDialog;                                                                

    TaskSetWallpaper(Context context)                                                              
    {                                                                                              
        this.context = context;                                                                    
    }                                                                                              

    @Override                                                                                      
    protected void onPreExecute()                                                                  
    {                                                                                              
        super.onPreExecute();                                                                      
        pDialog = new ProgressDialog(context);                                                     
        CharSequence text = getText(R.string.crop__wait);                                          
        pDialog.setMessage(text);                                                                  
        pDialog.setIndeterminate(false);                                                           
        pDialog.setCancelable(false);                                                              
        pDialog.show();                                                                            
    } …
Run Code Online (Sandbox Code Playgroud)

android messages wallpaper

1
推荐指数
1
解决办法
2267
查看次数