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
| 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
| /** | |
| * 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
| 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
| 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
| //https://stackoverflow.com/questions/7189948/full-screen-dialogfragment-in-android | |
| override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
| //val dialog = super.onCreateDialog(savedInstanceState) | |
| // request a window without the title | |
| //dialog.window!!.requestFeature(Window.FEATURE_NO_TITLE) | |
| // the content | |
| val root = RelativeLayout(activity) | |
| root.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) |
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
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen) | |
| } |
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
| 1. Find the longest String in an array of Strings | |
| //ANSWER: | |
| public String getLongestStringInArray(String[] array){ | |
| int index = 0; | |
| int elementLength = array[0].length(); | |
| int arraySize = array.length; | |
| for(int i=1; i< arraySize; i++) { |
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://stackoverflow.com/questions/25457737/how-to-create-an-observable-from-onclick-event-android | |
| Observable<View> clickEventObservable = Observable.create(new Observable.OnSubscribe<View>() { | |
| @Override | |
| public void call(final Subscriber<? super View> subscriber) { | |
| viewIWantToMonitorForClickEvents.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View v) { | |
| if (subscriber.isUnsubscribed()) return; | |
| subscriber.onNext(v); |
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
| //issue happens one pre lolipop devices | |
| //https://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working | |
| //must use NestedScrollView | |
| fix: | |
| mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { | |
| @Override | |
| public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { | |
| int action = e.getAction(); |