Skip to main content

Posts

Sign in with Phone Number using Digits

Today we are going to implement "Sign in with Phone Number" using Digits. I'm using Android Studio for development. So first we need to download and install Fabric plugin. Go to  https://fabric.io  and create account. After that you need to download Fabric plugin. Once you download and install plugin, you will see Fabric plugin icon in Android Studio. 1. Now create a sample project with one activity. 2. Click on that Fabric plugin button and you will see login page. 3. Enter username and password and login to Fabric.It will detect if any of it's kit installed in project or not.  4. Then click on install button of Digits Kit. Apply the changes in your project. After that it will add some data to your project as well as in AndroidManifest. That's it you are successfully integrate Digits kit in your Android project. Here is the activity_main.xml < LinearLayout xmlns:android= "http://schemas.android.com/apk/res/an...

WeekView in Android

Hello Friends,    Have you Searching for Android calender with WeekView.  Today I am sharing android tutorial for android custom calendar WeekView. WeekView.java public class WeekView extends ActionBarActivity implements OnItemClickListener, OnClickListener { private GridView mGrid; private GregorianCalendar mCalendar; private Date[] mWeek; private TextView mMonthText; private RelativeLayout mArrowRight; private RelativeLayout mArrowLeft; private CalendarAdapter mAdapter; private SimpleDateFormat mFormatMonth = new SimpleDateFormat("MMMM"); private SimpleDateFormat mFormatDay = new SimpleDateFormat("d"); private SimpleDateFormat mFormatYear = new SimpleDateFormat("yyyy"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_week_view); mGrid=(GridView)findViewById(R.id.gridview); mGrid.s...

Pull links from string in Android

Sample code: String Message="http://indianexpress.com/article/sports/football/mexico-holds-host-brazil-to-0-0-draw-at-world-cup/ http://indianexpress.com/article/sports/cricket/suresh-raina-surprised-by-stuart-binnys-performance/ http://indianexpress.com/article/sports/football/fifa-world-cup-every-match-is-like-a-final-for-us-says-andres-iniesta/" ArrayList<String> forrmatted=pullLinks(Message);  for(int i=0;i<forrmatted.size();i++){       String temp=forrmatted.get(i).toString();       Message=Message.replace(temp, "["+temp+"]"); } private ArrayList<String> pullLinks(String text) {  ArrayList<String> links = new ArrayList<String>();  String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]";  Pattern p = Pattern.compile(regex);  Matcher m = p.matcher(text);  while(m.find()) {     String urlStr = m.group(); ...

Get domain name from URL in android

Sample Code: String url="http://sports.in.msn.com/football-world-cup-2014/world-cup-animals-5"; String hostName=getDomainName(url); private CharSequence getDomainName(String shareURL) throws URISyntaxException {    URI uri = new URI(shareURL);    String domain = uri.getHost();     return domain; } above method return host name from given URL. You can get more from URL using below methods. uri.getProtocol(); uri.getAuthority(); uri.getHost(); uri.getPort(); uri.getPath(); uri.getQuery(); uri.getFile(); Output: protocol = http authority = sports.in.msn.com host = sports.in.msn.com port = -1 path = /football-world-cup-2014/world-cup-animals-5 query = null filename = /football-world-cup-2014/world-cup-animals-5

Custom Toast in Android

What is Toast? A toast is a view containing a quick little message for the user. When the view is shown to the user, appears as a floating view over the application. It will never receive focus.  Normal syntax of Toast is Toast.makeText(context, text, duration).show(); context the context to use. Usually your android.app.Application or android.app.Activity object. text The text to show. Can be formatted text. duration How long to display the message. Either LENGTH_SHORT or LENGHT_LONG. Here is the example: Toast.makeText(this, "Hello", Toast.LENGTH_LONG).show(); Now let's start with custom toast. Create an Android Project: CustomToastActivity.java public class CustomToastActivity extends ActionBarActivity implements OnClickListener { Button customToast; Button showToast; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_toast); s...

Check internet connectivity in Android

Write a class which check internet connectivity in android mobile ConncetionDetector.class public class ConnectionDetector { private Context _context; public ConnectionDetector(Context context){ this._context = context; } public boolean isConnectingToInternet(){ ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);  if (connectivity != null)   {  NetworkInfo[] info = connectivity.getAllNetworkInfo();  if (info != null)   for (int i = 0; i < info.length; i++)   if (info[i].getState() == NetworkInfo.State.CONNECTED)  {  return true;  }  }  return false; } } Activity: public class MainActivity extends ActionBarActivity { ConnectionDetector cd; public static boolean isInternetPresent = false; TextView info; @Override pr...

Load images from external storage into GridView with checkbox in Android using Picasso library

Activity: public class Gallery extends ActionBarActivity { public GridView imagegrid; private ArrayList<String> imageUrls; private ImagesAdapter imageAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); init(); } private void init() { final String[] columns= {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID}; final String orderBy= MediaStore.Images.Media.DATE_TAKEN; Cursor imageCursor= this.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, orderBy +" DESC"); this.imageUrls=new ArrayList<String>(); for(int i=0; i< imageCursor.getCount();i++){ imageCursor.moveToPosition(i); int dataColumnIndex =imageCursor.getColumnIndex(MediaStore.Images.Media.DATA); imageUrls.add(imageCursor.getString(dataColumnIndex)); }   imagegrid = (GridView) f...