Showing posts with label Java/Android. Show all posts
Showing posts with label Java/Android. Show all posts

How to work adb shell getprop and setprop command (connect adb, disconnect adb)

open(connect adb) -> setprop persist.sys.usb.config adb

close(disconnect adb) -> setprop persist.sys.usb.config hostadb    ( hostadb or hostabd) 


#How to work adb shell getprop and setprop? #adb shell #setprop #hostadb #hostabd #setprop persist #persist.sys.ub.config #connect adb #disconnect adb

How to push adb (Android) command

$ adb push <fileName> <DestinationPath>

 

Ex)
$ adb push test /storage/log 


#adb #android #adb push

How to capture Android(ADB) Command

$ adb shell screencap -p <PATH>

$ adb shell screencap -p /sdcard/screen.png 


#android #adb #screencap #screencapture 

java.net.SocketException: socket failed: EACCES (Permission denied)

App.manifests.Androidmanifest.xml

error:
java.net.SocketException: socket failed: EACCES (Permission denied)

solve:
add : Manifest.xml file

<uses-permissionandroid:name="android.permission.INTERNET"


example:

<?xmlversion="1.0"encoding="utf-8"?>
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidclient">

<uses-permissionandroid:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activityandroid:name=".MainActivity">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN"/>

<categoryandroid:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>



#Android #Java #Permission denied

Java Lotto / get random number example

This code was made in five minutes, so there are many weak point.

this code save that the number from 1 to 45 has been count N times.
finally, i will get 6 numbers.

import java.util.Random;

public class lottonamatja {
   public static void main(String[] args) {
      Random ranNum = new Random();    // random variable
      long[] cloneNum = new long[45]; 
      long[] num = new long[45];
      long[] lottoNum = new long[6];    // get real number(I wanted)
      long count = 1;
      long N = 100000000;
   
      for (long i = 0; i< N ; i++) {
         int tempRanNum = ranNum.nextInt(45)+1;    // random number of 1~45
         num[tempRanNum-1] += count;    // count of each number about N times
      }

//copy number
      cloneNum = num.clone();

// sorting count
      for (int i = 0; i < 45; i++) {
         for (int j = i + 1; j < 45; j++) {
            if (num[i] > num[j]) {
               long tmp = 0;
               tmp = num[i];
               num[i] = num[j];
               num[j] = tmp;
            }
         }
      }
   
// compare sorting number to original number ( this is real number(1~45), num[i] or cloneNum[j] is counting number)
      for (int i = 0 ; i < 6; i++) {
         for (int j = 0 ; j < 45; j++) {
            if (num[i] == cloneNum[j])
               lottoNum[i] = j+1;    // save result number 
         }
      }
   
// sorting about 6 number
      for (int i = 0; i < 6; i++) {
         for (int j = i + 1; j < 6; j++) {
            if (lottoNum[i] > lottoNum[j]) {
               long tmp = 0;
               tmp = lottoNum[i];
               lottoNum[i] = lottoNum[j];
               lottoNum[j] = tmp;
            }
         }
         System.out.print(lottoNum[i] + " ");    //i wanted to real number
      }
   }
}

Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore!

 🏙️ Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore! 🚨 Are you thinking about buying an apartment in 2025? 🏢  It’...