Archive

Archive for June, 2016

My new world rank on URI Online Judge

June 23rd, 2016 No comments

Rank: #49 / 71506

2016-06-24_01-23-24.jpg

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:

How to read JSON from assets in android?

June 20th, 2016 No comments

Very easy to do this.

First, store your JSON file in “assets” folder of your project.

in this example, i use the JSON file with the content like below:

2016-06-20_23-47-03.gif

Next, see code snippet below, try to read and understand how it work:

2016-06-20_23-48-58

That’s all i want to show you guys in this post.

Categories: Android Tags: ,

Quick Torch – a simple app for tutorial

June 11th, 2016 2 comments

Hi guys! Today i have a new simple project, this demonstrate how to implement and create a simple torch for Android.

This is an Open-Source project and source code is now available here.

 

 Some screen-shots:

Easy to use with the only icon in main screen

or you can even use with a widget always appear on your home screen.

2016_06_11_17.06.422016_06_11_17.07.13

 

Thank you!

Huy Nguyen

Categories: Android Tags: