Categories
Android 🏴‍☠️

Android : How to Add a Navigation Drawer and Implement Fragment

code : https://github.com/thana19/testNavigationDrawer

1. New Project with Navigation Drawer Activity

2. edit content_main.xml – add FrameLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="th.in.thana.testnavigationdrawer.MainActivity"
    tools:showIn="@layout/app_bar_main">

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>
Categories
Android 🏴‍☠️

Android : How to convert a image into base64Binary ?

 

imageView.buildDrawingCache();
Bitmap bitmap = profile_image.getDrawingCache();
String encodedImageData = getEncoded64ImageStringFromBitmap(bitmap);

============

public String getEncoded64ImageStringFromBitmap(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 70, stream);
byte[] byteFormat = stream.toByteArray();
// get the base 64 string
String imgString = Base64.encodeToString(byteFormat, Base64.NO_WRAP);

return imgString;
}