This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private boolean isMyServiceRunning(Class<?> serviceClass) { | |
| ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | |
| for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | |
| if (serviceClass.getName().equals(service.service.getClassName())) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Follow this code to sort any ArrayList | |
| Collections.sort(empList, new Comparator<Employee>(){ | |
| public int compare(Employee emp1, Employee emp2) { | |
| // ## Ascending order | |
| return emp1.getFirstName().compareToIgnoreCase(emp2.getFirstName()); // To compare string values | |
| // return Integer.valueOf(emp1.getId()).compareTo(emp2.getId()); // To compare integer values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.cool.vicky.contentprovider; | |
| import android.database.Cursor; | |
| import android.provider.ContactsContract; | |
| import android.support.v4.app.LoaderManager; | |
| import android.support.v4.content.CursorLoader; | |
| import android.support.v4.content.Loader; | |
| import android.support.v4.widget.SimpleCursorAdapter; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| view.post(new Runnable() { | |
| @Override | |
| public void run() { | |
| int width = view.getWidth(); | |
| int height = view.getHeight(); | |
| //do something cool with width and height | |
| } | |
| }); |
NewerOlder