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
| public static void openPDFFiile(Context context,File file){ | |
| //OPEN THE PDF | |
| String mimeTypeStr = "application/pdf"; | |
| Intent intent2 = new Intent(Intent.ACTION_VIEW); | |
| //intent2.setDataAndType(uri, mimeTypeStr); | |
| //Uri apkURI = FileProvider.getUriForFile( | |
| // context, | |
| // context.getApplicationContext() | |
| // .getPackageName() + ".provider", file); |
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
| AsyncTask.execute(new Runnable() { | |
| @Override | |
| public void run() { | |
| //ADD YOUR CODE TO EXECUTE IN BACKGROUND THREAD HERE | |
| } | |
| }); |
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
| /** | |
| * from here: https://stackoverflow.com/questions/22186778/using-math-round-to-round-to-one-decimal-place | |
| * @param value double value with decimal places 123.123456789 | |
| * @param precision 1 number of decimal places desired ex. 1 (result => 123.1) | |
| * @return | |
| */ | |
| public static double roundToDecimalPlaces(double value, int precision) { | |
| int scale = (int) Math.pow(10, precision); | |
| return (double) Math.round(value * scale) / scale; | |
| } |
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
| https://github.com/MindorksOpenSource/android-interview-questions#data-structures-and-algorithms | |
| https://www.toptal.com/android/interview-questions | |
| What is a ContentProvider and what is it typically used for? | |
| -A ContentProvider manages access to a structured set of data. It encapsulates the data and provide mechanisms for defining data security. ContentProvider is the standard interface that connects data in one process with code running in another process. | |
| Under what condition could the code sample below crash your application? How would you modify the code to avoid this potential problem? Explain your answer. | |
| Intent sendIntent = new Intent(); | |
| sendIntent.setAction(Intent.ACTION_SEND); |
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
| public class Logger { | |
| public static final void logd(String tag, String message){ | |
| Logger.d(tag, message); | |
| } | |
| public static void d(String TAG, String message) { | |
| int maxLogSize = 1000; | |
| for(int i = 0; i <= message.length() / maxLogSize; i++) { | |
| int start = i * maxLogSize; | |
| int end = (i+1) * maxLogSize; |
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
| //kotlin code | |
| editText. | |
| filters = arrayOf<InputFilter>(object : InputFilter.AllCaps() { | |
| override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence { | |
| return source.toString().toLowerCase() | |
| } | |
| }) | |
| //xml layout | |
| <?xml version="1.0" encoding="utf-8"?> |
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
| //recyclerview list item layout xml with scrollable textview | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| xmlns:card_view="http://schemas.android.com/apk/res-auto" | |
| 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:orientation="vertical" | |
| > <TextView |
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 void animateCountdown(final View textView){ | |
| ValueAnimator valueAnimator = ValueAnimator.ofFloat(1f, 0f); | |
| valueAnimator.setDuration(800); | |
| valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
| @Override | |
| public void onAnimationUpdate(ValueAnimator animation) { | |
| float alpha = Float.parseFloat(animation.getAnimatedValue().toString()); | |
| textView.setAlpha(alpha); | |
| } | |
| }); |
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
| /** | |
| * Usage: | |
| * val limit0to24 = EditTextInputFilter(0, 23) | |
| * val limitChars = EditTextInputFilter(arrayListOf("a","b","c","d","e","f","g","h", "ab", "cd")) | |
| * input1.setFilters(arrayOf(limit0to24)) | |
| * input2.setFilters(arrayOf(limitChars)) | |
| * | |
| */ | |
| class EditTextInputFilter : InputFilter { |
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
| ------------------------------------------------------------------- | |
| ------------------------build.gradle------------------------------- | |
| ------------------------------------------------------------------- | |
| /** | |
| * RxJava2 and RxAndroid2 gradle setup | |
| implementation 'com.android.support:design:26.1.0' | |
| compile group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.5' | |
| compile 'io.reactivex.rxjava2:rxandroid:2.0.1' | |
| */ |