小编Eda*_*izi的帖子

EditText drwableLeft不适用于矢量

在我的应用程序中,我使用在支持库23.2中添加的矢量drawables用于显示矢量图标,它工作得很好但是当我将矢量设置为EditText的drawableLeft时,它在pre-lollipop android版本中不起作用.在运行时,发生ResourceNotFound异常.

Caused by: android.content.res.Resources$NotFoundException: File 
res/drawable/layer_ic_user.xml from drawable resource ID #0x7f0200b3
Run Code Online (Sandbox Code Playgroud)

这是我的gradle配置:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
    applicationId "com.example.test"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    vectorDrawables.useSupportLibrary = true
    generatedDensities = []
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
       'proguard-rules.pro'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/res/assets/'] } }
  }

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0' …
Run Code Online (Sandbox Code Playgroud)

android vector

10
推荐指数
2
解决办法
2328
查看次数

如何禁用通知小图标?

如何disablehide通知小图标?我知道这是强制性的,但我想隐藏或删除小图标并只显示大图标。

Notification.Builder builder = new Notification.Builder(FcmIntentService.this).setSmallIcon(R.drawable.notification_small_icon_transparent);
NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(11, builder.build());
Run Code Online (Sandbox Code Playgroud)

我想要这样的 google plus 通知:

在此处输入图片说明

notifications icons android android-layout android-notifications

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

如何使用 android studio 中的终端从特定的“.gradle”文件运行 gradle 任务?

我是编写 Gradle 任务的新手。

我已将一个.gradle文件添加到我的项目的根目录中,该gradle文件中有一些任务,我的问题是如何在 android studio 中运行这些tasks任务Terminal

Gradle任务

当我在 android studio 中使用终端运行任务时,它返回以下错误:

Task 'testTask' not found in root project 'TestProject'.
Run Code Online (Sandbox Code Playgroud)

android gradle gradlew android-studio gradle-task

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

使用getActiveNetworkInfo检查android中的互联网连接

如果您想在android中检查互联网连接,则有很多方法可以做到这一点,例如:

   public boolean isConnectingToInternet(){
    ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
      if (connectivity != null) 
      {
          NetworkInfo[] info = connectivity.getAllNetworkInfo();
          if (info != null) 
              for (int i = 0; i < info.length; i++) 
                  if (info[i].getState() == NetworkInfo.State.CONNECTED)
                  {
                      return true;
                  }

      }
      return false;
    }
Run Code Online (Sandbox Code Playgroud)

getAllNetworkInfo(); 在api级别23中已弃用,因此我需要一种解决方案来检查api级别23和以前的互联网连接,我发现了另一种方法

 private boolean isConnectedToInternet()
{
    ConnectivityManager cm = (ConnectivityManager) SplashActivity.this.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
        if (activeNetwork != null) { // connected to the internet
            if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
                // connected to …
Run Code Online (Sandbox Code Playgroud)

android internet-connection

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