Testing app di Android Studio menggunakan device Android via Wifi

Bagi yang ribet menggunakan kabel untuk melakukan pengujian aplikasi ke device/hardware Android, anda dapat mengikuti cara mudah berikut ini. Di artikel ini diberikan 2 opsi melakukan pengujian aplikasi dari Android Studio ke device Android dengan perantara nirkabel/wifi.

Metode Pertama.

  • Nyalakan debugging mode di Pengaturan HP/device Android.
  • Koneksikan kabel usb dari laptop/PC ke HP Android (ini untuk inisialisasi saja, seterusnya tidak diperlukan lagi)
  • Gunakan command prompt/terminal yang sudah bisa menggunakan perintah “adb” (atau ya kalau belum paham, tinggal arahkan saja ke path lokasi SDK Android dan masuk ke directory sdk/platform-tools/ di dalamnya ada batch file adb)
  • Ketik:
    adb tcpip 5555[enter]
  • setelah itu cek IP Address HP/device Android dengan cara ketik:
    adb shell netcfg
  • Setelah anda mengetahui IP Address dari device/HP anda, dicatat/diingat, kemudian ketikkan perintah dengan format berikut:
    adb connect [IP_Address_device]:5555
    Contoh: adb connect 192.168.1.6:5555[enter]
    nanti akan muncul response:

    “connected to 192.168.1.6:5555” (ini tidak perlu diketik ya..ini akan muncul kalau anda berhasil menghubungkan HP/device android ke laptop via IPaddress secara wireless)

  • Setelah itu lepas kabel usb dari HP/device Android dan laptop/PC anda.
  • Dan selamat menikmati, Android Studio anda sudah bisa melakukan testing ke device/HP Android tanpa terhubung dengan kabel usb.
  • Bila anda sudah selesai melakukan testing aplikasi, anda dapat menutup koneksi wireless dari HP ke laptop anda dengan perintah berikut:
    adb -s [IP_address_device]:5555 usb [enter]

Cukup ribet ya cara di atas? atau masih ada yang gagal mencoba? Move-on dong..mari coba metode ke-dua.

Metode Kedua.

  1. Dari Android Studio kamu, masuk ke Preferences, dengan cara:
    Android Studio: Preferences/Settings->Plugins->Browse Repositories
  2. Install Plugins dengan mengetikkan: “Android WiFi ADB” dan pilih install sesuai petunjuk di layar.
  3. Setelah selesai Install, apabila diminta restart, pilih “restart”
  4. Selamat, plugins Android WiFi ADB berhasil diinstall. Sekarang bagaimana cara menggunakannya ya? Lanjut ke step ke-5.
  5. Mau testing di device Android, tentu jangan lupa nyalakan DEBUGGING mode (pokoknya wajib, masih belum ngerti? bisa bertanya atau cari diinternet, seharusnya developer Android tau langkah mudah mengaktifkan debugging mode ini)
  6.  

    Cari opsi “DEBUG OVER TCP/NETWORK” di dalam Menu Pengaturan/Settings device/HP android kamu>Developer Options.

  7.  

    Pasang kabel USB dari HP ke Laptop/PC, dan pastikan keduanya (PC dan HP) menggunakan jaringan internet yang sama (ntah hotspot ataupun wifi)

  8.  

    Pilih icon ANDROID Wifi ADB di Android Studio.

  9.  

    Setelah itu, device/hp kamu akan terdeteksi di situ, dan siap digunakan untuk testing (jangan lupa cabut kabel USBnya yah pas menggunakan plugins Android Wifi ADB ini)

Selamat mencoba.

 

Advertisements

Enable multiple users & user session on Android

Multiple User Mode is the ability to give the phone to another person, let them log in with their own account information, and any changes they make are done under their account. They give the phone back to you, and you’ll have none of their clutter, photos, emails, or apps on your account.

Preparation :

  1. You’ll either need root access (rooting) on your Android device, ADB tools via commandprompt, or a terminal emulation application installed.
  2. In a terminal window or ADB, you’ll need to obtain SuperUser/root access. This is generally done by typing :
    adb shell [enter]
    su [enter]
    After obtaining SuperUser access, type in:
    pm get-max-users [enter]
    note : if pm get-max-users failed, maybe package manager not supported on your device, it’s no problem at all. 😉
  3. Now type in:
    setprop fw.max_users 8 [enter]
    note : this will create privilages for maximum number of users supported by the device
  4. Then, type in :
    pm create-user [usernameyouwanthere] [enter]
    example : create-user Guest [enter]

    For another pm (package manager) cheatsheet, you can visit this.

And, viola! you can try to “press and  hold” power button, if it is successful, it will show like this :

Image

[Tips for Android Developer] Move your applications to External Storage (SDcard)

Many android users have a big problem with disk space. Every Applications on the device should be installed on the device’s internal memory.

But, in Froyo and above allows you to install application on the external storage (SD Card), but if only the developer actually enables that feature in his application.

According to the http://developer.android.com/guide/appendix/install-location.html, developer can set his application’s install location to the external storage by set android:installLocation attribute with a value of “auto” or “preferExternal” in the <manifest> element.

How about usual or ordinary users?

Yeah, it’s easy to do that with command prompt or terminal window and of course, you need ADB Tools (or Android SDK).

  1. Please, make sure that you enabled “USB debugging” mode on your phone.
  2. You need the Android SDK or ADB tools. Please install it to your computer.
  3. Connect your phone to a USB port, open up a terminal window (command prompt), and type “adb shell pm setInstallLocation 2” (without the quotes). (ADB is part of the Android SDK.
    This will enable the move to SD card option for all applications.)
  4. Now, press menu button, go to the Settings menu > Applications menu and move your apps to your SD card.
  5. To restore this setting back to default type “adb shell pm setInstallLocation 0“.

Done! 😀
You’ve got the point of success with this. And enjoy your applications..they should be stored on the sd card. 🙂

[Tips for Android Developer] Using Android Emulator or Android Virtual Device

If you don’t have a android phone, don’t worry..you can still develop apps android and try it through Android Emulator (Android Virtual Device – AVD)

you can use the command via command prompt (don’t forget to set adb tools on system variable path on your PC) :

emulator -avd emulator-name

to start the emulator. If you want to customize the emulator appearance, you can use the command:

emulator -avd emulator-name -skin 480×320

where the Andori emulator appearance standard is:

480×320, landscape: emulator -skin HVGA-L
320×480, portrait : emulator -skin HVGA-P (default)
320×240, landscape: emulator -skin QVGA-L
240×320, portrait : emulator -skin QVGA-P