Tag Archives: Android

Android:Field can be converted to a local varible.

background

It’s been a while since Android studio was used to develop Android. Occasionally, as has a yellow highlight on some private variables field can be converted to a local variable . I still don’t want to see this yellow highlight for some obsessive-compulsive disorder. Baidu did not find any useful information, or Google search to find some answers.

analysis

The complete description of field can be converted to a local variable is (hand play only): field can be converted to a local variable :

This inspection searches for redundant class fields that can be replaced with local variables,if all local usages of a field are preceded by assignments to that field,the field can be removed and its usages replaced with local variables.

This means that it is detected that this variable can be replaced by a local variable. It is recommended to delete it and write it as a local variable.

Solution

Delete the sentence private XXX; and declare and instantiate it directly where it is used.
In Android studio for Mac , you can use the shortcut key Alt + enter to quickly convert local variables.

PS: you still need better English. In fact, you can understand it by reading the instructions. You don’t need to search in this way.

Failed to mount / cache (no such device)

After fastboot swiped the ROM of CM13, ADB sideload was used to swiped the ROM, but every time there was an error on the phone

E: failed to mount /cache (No such device)

The fastboot-w command can not be used to retrieve the cache from the cache. It can not be used to retrieve the cache from the cache. The fastboot-w command can not be used to retrieve the cache.

-w erase userdata and cache (and format if supported by partition type)

Double-clear operations will also be done, and partitions will be rebuilt

wiping userdata...
Creating filesystem with parameter
    Size: 13610496000
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8160
    Inode size: 256
    Journal blocks: 32768
    Label:
    Blocks: 3322875
    Block groups: 102
    Reserved block group size: 815

Failed to mount /cache error will not be reported again after the adb sideload is executed.
E:Can’t mount /cache/recovery/log

Default interface methods are only supported starting with Android N (–min-api 24): com.XXXX

Recently, AndroidStudio has encountered this problem for the first time running a project. I don’t know the specific reason, but the solution is as follows.
Add the following to your app’s build.gradle file under the Android TAB.

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Error record: this.requestWindowFeature ( Window.FEATURE_ NO_ Title) error or no effect

The requestWindowFeature method must be placed before the content view is initialized. I checked that this is the first one, but later I found that I changed the class inheritance. Before I inherited the Activity, I changed the class inheritance to AppCompatActivity.
At first I wondered if it was possible that AppCompatActivity had done something in its own super.onCreate. So the

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

On the

super.onCreate(savedInstanceState);

Finally, in the manifests file, we add an attribute to the Activity:

android:theme="@style/Theme.AppCompat.Light.NoActionBar"

solves the problem.

The title bar is not an ordinary title bar. It is called ActionBar. Another solution is to call it after setContentView

getSupportActionBar().hide();

solves the problem.

Request window feature for Android Development( Window.FEATURE_ NO_ Title) does not take effect

What if you want to hide the ActionBar but the requestWindowFeature(window.feature_no_title) doesn’t work?
Reason: because they define the Activity of inherited android. Support. V7. App. AppCompatActivity, AppCompatActivity itself does not support requestWindowFeature (Window. FEATURE_NO_TITLE) cause, can change to inherit the Activity.

Android set request window feature( Window.FEATURE_ NO_ Title) invalid solution

Reprint please indicate the source: http://blog.csdn.net/java201159416/article/details/51940074

general app has a demand to hide the Android default Title bar, is usually used before setConvertView call requestWindowFeature (Window. FEATURE_NO_TITLE), after can sometimes find call this line of code has no effect, Very depressed.
through observation, before the Activity is to inherit the Activity, so is valid, and I am AppCompatActivity inherited, so can’t hide.
solution:
1. Let xxxActivity inherit the Activity
2. Inherit AppCompatActivity and call it in the onCreate method

if (getSupportActionBar() != null){
   getSupportActionBar().hide();
}

And then we’re done.

[Android] using request window feature( Window.FEATURE_ NO_ Title) method to remove the title invalid solution

I used to use Eclipse to write APP, but today I try to use Android Sutido to write APP. I need to hide the title bar in the APP and use a custom title bar. It turns out that using requestWindowFeature(window.feature_no_title) method has no effect, and the title is not hidden

public class TitlebarActivity extends AppCompatActivity

In Android Studio, activities inherit from AppCompatActivity by default, so the requestWindowFeature(window.feature_no_title) method fails.

There are two solutions

    > change AppCompatActivity to Activity, then requestWindowFeature(window.feature_no_title); Add the following code to the onCreate() method:
if (getSupportActionBar() != null){
   getSupportActionBar().hide();
}

Now you can hide the title bar.

Android android.intent.category Purpose and use of. Launcher

The Android Android. Intent. The category. The purpose and use of the LAUNCHER
Sometimes we just create a new Android project in Eclipse, run it, and then we have an APK on the phone with the logo; We seldom consider no icon apk, however, this is to say the android. Intent. The category. The LAUNCHER.
1: we see first with android. The intent. The category. The effect of the project after the operation the LAUNCHER
1.1: project name as

1.2: the manifest. XML is as follows: (note contains android. The intent. The category. The LAUNCHER)

1.3: After running the effect, you can see the screen shot of the phone (you can see there is a launcher (CP3))

2: we can’t see with android. Intent. The category. The effect of the project after the operation the LAUNCHER
2.1: project name as

2.2: the manifest. XML is as follows: (note that there is no android. The intent. The category. The LAUNCHER)

2.3: after the operation, you can see on the screen without any effect
2.4 console display as follows:

indeed installed.
2.5: this time we enter the verify directory:

You can see that it contains com.tcl.cp3-2.apk.
1 and 2 contrast can be found in the android. Intent. The category. The role of the LAUNCHER.

Differences between Java and kotlin access modifiers

modifiers

Java

Kotlin

public

all kind of visible

all kind of visible (the default)

private

current class visible

current class visible

prote Cted

the current class, subclass, class is visible under the same package path

the current class, subclass visible

default

class visible (the default) under the same package path

no

internal

no

class is visible in the same module