Wednesday, 13 July 2016

Convert 24 hours format to 12 hours format


change date format : 24 to 12 hours


 public static String Convert24to12(String time) {
        String convertedTime = "";
        try {
            SimpleDateFormat displayFormat = new SimpleDateFormat("hh:mm a",Locale.US);
            SimpleDateFormat parseFormat = new SimpleDateFormat("HH:mm:ss",Locale.US);
            Date date = parseFormat.parse(time);
            convertedTime = displayFormat.format(date);
            System.out.println("convertedTime : " + convertedTime);
        } catch (final ParseException e) {
            e.printStackTrace();
        }
        return convertedTime;
        //Output will be 10:23 PM
    }

Android underline in Textview


display underline with textview in android


 public static void mekeUnderLine(Context context, TextView textView) {
        Paint p = new Paint();
        p.setColor(context.getResources().getColor(R.color.app_pink));
        textView.setPaintFlags(p.getColor());
        textView.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
    }

Android - get Bitmap from url


 get image bitmap from web url


public static Bitmap getBitmapFromURL(String imageUrl) {
    try {
        URL url = new URL(imageUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoInput(true);
        connection.connect();
        InputStream input = connection.getInputStream();
        Bitmap myBitmap = BitmapFactory.decodeStream(input);
        return myBitmap;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

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...