Universal Acceptance of Email id on android platform In Kotlin (UASG)

Standard

UASG : Universal Acceptance is a foundational requirement for a truly multilingual Internet, one in which users around the world can navigate entirely in local languages.

Use this email validation function :


fun isEmailValid(email: String): Boolean {
var isValid = false
val expression = "[^ ]+@[^ ]+\\.[^ ]{2,63}"
val pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE)
val matcher = pattern.matcher(email)
if (matcher.matches()) {
isValid = true
}
return isValid
}

Full sample source code Link :
Soruce Code – written in Android-Kotlin

Android New Permission system

Standard

Hey Are you android developer? If yes then you must know about new Android’s Runtime Permission !!!

Old android permission system

User has to accept every single permission at install time and they will be all granted once installed !

But Now in Api 23 (6.0 Marshmallow)

Application will not be granted any permission at installation time. Instead, application has to ask user for a permission one-by-one at runtime.

And important thing is that permission request dialog shown above will not launch automatically. Developer has to call for it manually. In the case that developer try to call some function that requires a permission which user has not granted yet, the function will suddenly throw an Exception which will lead to the application crashing. runtimepermissioncrashFor application that has already been launched?

Android team has already thought about it. If the application’s targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior.

Automatically granted permissions

There is some permission that will be automatically granted at install time and will not be able to revoke. We call it Normal Permission .

android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_NOTIFICATION_POLICY
android.permission.ACCESS_WIFI_STATE
android.permission.ACCESS_WIMAX_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.BROADCAST_STICKY
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.CHANGE_WIMAX_STATE
android.permission.DISABLE_KEYGUARD
android.permission.EXPAND_STATUS_BAR
android.permission.FLASHLIGHT
android.permission.GET_ACCOUNTS
android.permission.GET_PACKAGE_SIZE
android.permission.INTERNET
android.permission.KILL_BACKGROUND_PROCESSES
android.permission.MODIFY_AUDIO_SETTINGS
android.permission.NFC
android.permission.READ_SYNC_SETTINGS
android.permission.READ_SYNC_STATS
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.REORDER_TASKS
android.permission.REQUEST_INSTALL_PACKAGES
android.permission.SET_TIME_ZONE
android.permission.SET_WALLPAPER
android.permission.SET_WALLPAPER_HINTS
android.permission.SUBSCRIBED_FEEDS_READ
android.permission.TRANSMIT_IR
android.permission.USE_FINGERPRINT
android.permission.VIBRATE
android.permission.WAKE_LOCK
android.permission.WRITE_SYNC_SETTINGS
com.android.alarm.permission.SET_ALARM
com.android.launcher.permission.INSTALL_SHORTCUT
com.android.launcher.permission.UNINSTALL_SHORTCUT

Declare those permissions in AndroidManifest.xml and it will work. No need to check for the permission.

Note:

When you create a new project in Android Studio. targetSdkVersion will be automatically set to the latest version, 23. If you are not ready to make your application fully support the Runtime Permission, I suggest you to set targetSdkVersion to 22.

Own Android Flashligth Application With widget

Standard

Android flashlight App with widget on Google play store.

Application Title: “Jugnu Flashlight”

unnamed

Link : Jugnu Flashlight Download

Feature :  Very easy and useful Flashlight tool with Widget and Shake functionality.

– Single Click for flashlight On/Off
– Quick access by Widget and simple UI
– Provide Shake Functionality for On/Off flashlight in Background.
– Also Provide Background Service for On/Off
with Shake Handset and control flashlight feature.
– And NO NEED TO UNLOCK SCREEN for On and off.
– Battery Maintain

If you like please rate these app .

Full Source Code upload in next post.
(suggestions are welcome ..)

“extends Fragment” Support getSupportActionbar() AppCompat v7 lib????

Standard

– AppCompat/ActionBarCompat in v7 support library.

if extends with “Fragment” not with “ActionBarActivity” then

After Fragment.onActivityCreated() you’ll have a valid activity accessible through getActivity().

You’ll need to cast it to an ActionBarActivity then make the call to getSupportActionBar().

example:

ActionBar actionbar=((ActionBarActivity)getActivity()).getSupportActionBar();

actionbar..setTitle(“title”);

……… hide,subtitle and all work  with extends Fragment.

 

Image Loading Problem. ??? Images take time to download and display ??

Standard

Best Solution is use Picasso lib (Picasso.jar)

Picasso Library(Free) to take care of everything for you. You just add one line of code! Very easy and simple! There are lots of lib are available . valley.jar is one of the best lib. But i thing Picasso is very simple and easy to use  .

Single line Code:

Picasso.with(context).load(image_url).placeholder(R.drawable.circle_process)
.error(R.drawable.gpimage_error)
.into(holder.gpimage1);

Sample web service integrated application image like FB feed.

Sample web service integrated application image like FB feed.

Picasso lib Details:

Picasso is a powerful image downloading and caching library package which you include in your app build. It simplifies working with images, reducing the code that you need to use to one line of code.

it’s free and Open Sourced? Check out the Picasso website

useful reference article and tutorial sources:
1) Picasso website
2) http://www.101apps.co.za/articles/using-bitmaps-efficiently.html

Simple SMS Sending from an Android Phone

Standard

Introduction

In this article we will explore all possible ways to achieve this simple yet very useful task.

There are two possible ways to send a text message from an Android app
1. The first way is to send it programmatically from your application.

 Step 1- And permission in your AndroidManifest.xml file

<uses-permission android:name="android.permission.SEND_SMS" />

Step 2 – 

Import the package –

import android.telephony.SmsManager

Step 3 – Create New function for send SMS

public void sendSMS() {
    String phoneNumber = "0123456789";
    String message = "Checking SMS From GP!";

    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(phoneNumber, null, message, null, null);
}

The method sendTextMessage of class SmsManager sends a text based SMS.

Method Detail-

public void sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)

If you use the code above you will able to send messages with length less than or equal to 160 characters only.

  • Code to send a long SMS

public void sendLongSMS() {
 
    String phoneNumber = "0123456789";
    String message = "Hello World! Now we are going to demonstrate " + 
            "how to send a message with more than 160 characters from your Android application.";

    SmsManager smsManager = SmsManager.getDefault();
    ArrayList<String> parts = smsManager.divideMessage(message); 
    smsManager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
}

The method sendMultipartTextMessage of class SmsManager sends a multi-part text based SMS

 

2. The second way is to send it by invoking the built-in SMS application.

waiting. For tomorrow. Sorry.. .