Archive

Archive for the ‘Android’ Category

Gradle: resolving dependencies :app:_debugCompile too long.

July 20th, 2016 No comments

It’s really a long day because this problem make me mad with my computer.

Holyshit! why i have to wait too long with this message below?

LZ4Jn

After browsing somewhere at StackOverFlow, I finally found a solution here:

http://stackoverflow.com/questions/27648966/android-studio-stuck-on-gradle-resolving-dependencies

 

Categories: Android Tags:

TextView: How to make it scrollable without using ScrollView?

July 18th, 2016 No comments

You don’t need to use ScrollView. How to do that?

Step 1. From XML, add some properties for TextView, like this:

Step 2. In your code: yourTextView.setMovementMethod(new ScrollingMovementMethod());

 

Categories: Android Tags:

For TextView android

July 11th, 2016 No comments

 

Categories: Android, Java Tags: ,

Debugging Android application via a wireless connection?

June 21st, 2016 5 comments

Sometime you don’t want to use USB cable (directly connect your device to computer) or you have problems with USB ports on your computer or something else.

Today, i finally found a really good solution to do this, it’s very simple. Read carefully all following steps below:

Step 1: Connect your device to computer via USB cable, make sure that “debugging mode” is activated. android device and computer must be connected to the same WIFI network (if you don’t know how to enable debugging mode,please search by google with keyword: “enable debugging mode in android”).
Step 2: Open CMD and run this command: adb tcpip 5555
Step 3: Run this command: adb shell netcfg to get your android device’s IP address.
Step 4: Continue to run command adb connect <IP_ADDRESS>:5555 and wait for a couple of seconds and then disconnect USB connection. Now you can properly run application in Android studio/eclipse, your device’s name still listed on the device choosing dialog, that really amazing!
When done, run this command: adb -s <IP_ADDRESS>:5555 usb to rollback to the previous setting (debugging via USB directly option).

 

Cheers
Huy N
http://mhuy.xyz

Categories: Android Tags: ,

How to change screen orientation programmatically?

June 20th, 2016 No comments

[code lang=”java”]
&lt;br /&gt;Configuration config = getResources().getConfiguration();

android.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

switch(config.orientation) {
case Configuration.ORIENTATION_LANDSCAPE:
// Device is now in landscape mode.
MyLandscapeFragment fragment = new MyLandscapeFragment();
fragmentTransaction.replace(android.R.id.fragmentLayoutId, fragment);
break;
default:
// Device is now in portrait mode.
MyPortraitFragment fragment = new MyPortraitFragment();
fragmentTransaction.replace(android.R.id.fragmentLayoutId, fragment);
break;
}
fragmentTransaction.commit();

[/code]

finally go to android manifest and make some changes for specified activity:

 

Categories: Android Tags: