Friday, 29 September 2017

Problem with extra space at the bottom of android Webview



String s="<head><meta name='viewport' content='target-densityDpi=device-dpi'/></head>";

webview.loadDataWithBaseURL(null,s+htmlContent,"text/html" , "utf-8",null);

Convert arraylist to json sting usnig Gson and exclude column

Sample class:-

public class MediaItem extends BaseModel {


    @PrimaryKey(autoincrement = true)
    long itemId;

    @Expose    @Column    String tracker_category;

    @Expose    @Column    String tracker_subcategory;

    @Expose    @Column    String tracker_problem_fixed;

    @Expose    @Column    String tracker_remarks;

    @Expose    @Column    String tracker_client_initial;


    public MediaItem() {
    }

    @Override    public String toString() {
        return "UploadToAccount{" +
                "itemId=" + itemId +
                ",tracker_category='" + tracker_category + '\'' +
                ",tracker_subcategory='" + tracker_subcategory + '\'' +
                ",tracker_problem_fixed='" + tracker_problem_fixed + '\'' +
                ",tracker_remarks='" + tracker_remarks + '\'' +
                ",tracker_client_initial='" + tracker_client_initial + '\'' +
                '}';
    }

    public long getItemId() {
        return itemId;
    }

    public void setItemId(long itemId) {
        this.itemId = itemId;
    }

    public String getTracker_category() {
        return tracker_category;
    }

    public void setTracker_category(String tracker_category) {
        this.tracker_category = tracker_category;
    }

    public String getTracker_subcategory() {
        return tracker_subcategory;
    }

    public void setTracker_subcategory(String tracker_subcategory) {
        this.tracker_subcategory = tracker_subcategory;
    }

    public String getTracker_problem_fixed() {
        return tracker_problem_fixed;
    }

    public void setTracker_problem_fixed(String tracker_problem_fixed) {
        this.tracker_problem_fixed = tracker_problem_fixed;
    }

    public String getTracker_remarks() {
        return tracker_remarks;
    }

    public void setTracker_remarks(String tracker_remarks) {
        this.tracker_remarks = tracker_remarks;
    }

    public String getTracker_client_initial() {
        return tracker_client_initial;
    }

    public void setTracker_client_initial(String tracker_client_initial) {
        this.tracker_client_initial = tracker_client_initial;
    }
}


// convert

ArrayList<MediaItem> arrayList = new Arraylist();// add some value
JsonArray myCustomArray = gson.toJsonTree(arrayList).getAsJsonArray(); 


// if require any field exclude
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
JsonArray myCustomArray = gson.toJsonTree(arrayList).getAsJsonArray(); 


Run/install/debug Android applications over Wi-Fi ?

Open Teminal/cmd --------------- Below steps is for Android 10 or lower Step 1 - Connect the device via USB and make sure debugging is work...