iWIN 必須被解散!

Weil Jimmer's BlogWeil Jimmer's Blog


Category:Note

Found 30 records. At Page 6 / 6.

Android Studio 安裝 Lib (Jar檔案) 圖文說明
No Comments

發布:
更新:2018-03-28 12:24:14

首先,要有要安裝的 Lib 檔案 ,是 「JAR」 版本的。

把JAR檔案丟進 專案 APP 下的 libs 資料夾!如下圖:(用拖拉還有按右鍵貼上都行)

(如果在Android Studio沒有找到 libs 資料夾,是根目錄設定成Android、改成Project,並展開app,就會找到了。或是你可以直接開檔案瀏覽器貼上。)

然後 編輯 「Build.gradle」。

在裡面加上程式碼:

    compile files('libs/jsoup-1.8.2.jar')//檔案名要改一下

注意:非常重要,是 「compile file『s」,那個 s 不要忘記!

如圖所示:

接著 Android Studio 可能會提示使用者 要重新編譯,就按下編譯吧!最後只差匯入命名空間:

import org.jsoup.Jsoup; //要改成你的Lib的名稱

接著就可以使用你安裝的 lib 了。

By Weil Jimmer


This entry was posted in Android, Functions, Java, Note By Weil Jimmer.

Java【解決方法】Byte[]、UByte[]的問題 Byte有負號
No Comments

發布:
更新:2016-01-06 18:37:17

    String str = "這是測試!ABC123.";
    byte[] bytes = {};
    try {
        bytes = str.getBytes("UTF-8");
    }catch(Exception ex){
    }
    for(int i=0;i<bytes.length;i++){
        System.out.println(bytes[i]);
    }
    System.out.println(bytes);

我們都知道,其實,Java裡面本身並不支援Ubyte。若真要使用差不多的功能,建議可以改用Short。

Ubyte就是沒有負號,而Byte就是可能會有負號。跟轉成二進制之後的高位補數與否有關係的樣子。

在此提供解決方法。直接看Code。

    //將字串以UTF8編碼轉成Ubyte[](實際上是short[]型別)
    public static short[] StringtoUByte(String str) {
        byte[] bytes = {};
        try {
            bytes = str.getBytes("UTF-8");
        }catch(UnsupportedEncodingException ex){

        }
        return BytetoUByte(bytes);
    }

    //將Ubyte[]以UTF8編碼轉成字串(實際上是short[]型別轉成字串)
    public static String UBytetoString(short[] ubytes) {
        byte[] bytes = UBytetoByte(ubytes);
        String str = "";
        try{
            str = new String(bytes,"UTF-8");
        }catch (Exception ex){

        }
        return str;
    }

    //將Ubyte[]轉成byte[](將short[]轉成byte[])
    public static byte[] UBytetoByte(short[] ubytes) {
        byte[] bytes = new byte[ubytes.length];
        for(int i=0;i<bytes.length;i++){
            bytes[i]=signedToBytes(ubytes[i]);
        }
        return bytes;
    }

    //將byte[]轉成Ubyte[](將byte[]轉成short[])
    public static short[] BytetoUByte(byte[] bytes) {
        short[] ubytes = new short[bytes.length];
        for(int i=0;i<bytes.length;i++){
            ubytes[i]=unsignedToBytes(bytes[i]);
        }
        return ubytes;
    }

    //將byte轉成Ubyte(將byte轉成short)
    public static short unsignedToBytes(byte b) {
        return (short)(b & 0xFF);
    }

    //將Ubyte轉成byte(將int轉成byte)
    public static byte signedToBytes(int b) {
        return ((byte)(b & 0xFF));
    }

可能看官們都注意到,byte轉ubyte都是 一樣的寫法。==> b & 0xFF

只是給他加個二進位負號而已,再加一個負號又變回原樣了。So,解釋完畢,上面的代碼自行取用吧。


This entry was posted in Java, Note By Weil Jimmer.

異步任務Java Android
No Comments

發布:
更新:2015-07-10 16:34:11

 public class ExcuteAsyncTaskOperation extends AsyncTask<Void, Integer, String>{

        @Override
        protected void onPreExecute() {
            //執行UI設定
            super.onPreExecute();
        }

        @Override
        protected String doInBackground(Void... params) {
            //進行背景工作,如「Network」,並可轉發值。
            //在迴圈中使用publishProgress((onProgressUpdate引數類別)變數);以傳遞資料。
            //例如publishProgress((int)50);
            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... progress) {
            //設定更新進程條
            //setProgressPercent(progress[0]);
        }

        @Override
        protected void onPostExecute(String result) {
            //結束,更新UI介面
            super.onPostExecute(result);
        }
    }

運行方法

    new ExcuteAsyncTaskOperation().execute();

This entry was posted in Java, Note By Weil Jimmer.

純筆記
No Comments

發布:2015-05-28 21:22:20

不解釋。

http://drops.wooyun.org/category/mobile


This entry was posted in Note By Weil Jimmer.

Android Java Activity 事件
No Comments

發布:2015-05-17 16:50:36

image

引用自:

https://www.thenewboston.com/forum/topic.php?id=3234


This entry was posted in Android, Experience, Functions, Java, Note By Weil Jimmer.

最前頁 上一頁  1 2 3 4 5 6 /6 頁)

Visitor Count

pop
nonenonenone

Note

支持網路中立性.
Support Net Neutrality.

飽暖思淫欲,饑寒起盜心。

支持臺灣實施無條件基本收入

歡迎前來本站。

Words Quiz


Search

Music

Blogging Journey

4227days

since our first blog post.

Republic Of China
The strong do what they can and the weak suffer what they must.

Privacy is your right and ability to be yourself and express yourself without the fear that someone is looking over your shoulder and that you might be punished for being yourself, whatever that may be.

It is quality rather than quantity that matters.

I WANT Internet Freedom.

Reality made most of people lost their childishness.

Justice,Freedom,Knowledge.

Without music life would be a mistake.

Support/Donate

This site also need a little money to maintain operations, not entirely without any cost in the Internet. Your donations will be the best support and power of the site.
MethodBitcoin Address
bitcoin1gtuwCjjVVrNUHPGvW6nsuWGxSwygUv4x
buymeacoffee
Register in linode via invitation link and stay active for three months.Linode

Support The Zeitgeist Movement

The Zeitgeist Movement

The Lie We Live

The Lie We Live

The Questions We Never Ask

The Questions We Never Ask

Man

Man

THE EMPLOYMENT

Man

In The Fall

In The Fall

Facebook is EATING the Internet

Facebook

Categories

Android (7)

Announcement (4)

Arduino (2)

Bash (2)

C (3)

C# (5)

C++ (1)

Experience (50)

Flash (2)

Free (13)

Functions (36)

Games (13)

General (57)

HTML (7)

Java (13)

JS (7)

Mood (24)

Note (30)

Office (1)

OpenWrt (5)

PHP (9)

Privacy (4)

Product (12)

Python (4)

Software (11)

The Internet (24)

Tools (16)

VB.NET (8)

WebHosting (7)

Wi-Fi (5)

XML (4)