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
| Одна из самых раздражающих недоработок Android проявляется когда нужно из фрагмента получить | |
| изображение с камеры или выбрать из готовых. | |
| Для этого используется Fragment.startActivityForResult(), а результат приходит в Fragment.onActivityResult(). | |
| Всё бы хорошо, но если фрагмент является потомком другого фрагмента, onActivityResult() не вызывается. | |
| Решается не очень тривиально: | |
| startActivityForResult() вызываем не для текущего фрагмента, а для родителя: | |
| private Fragment getActivityStarterFragment() { | |
| if (getParentFragment() != null) { | |
| return getParentFragment(); |
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
| LTR We will send an SMS with a confirmation code to your phone number: %s | |
| On screen: We will send an SMS with a confirmation code to your phone number: +380123456789 | |
| RTL \u202Cאנו נשלח הודעת SMS עם קוד אישור למספר הטלפון שלך:\u202A %s | |
| You can embed bidi regions using unicode format control codepoints: | |
| Left-to-right embedding (U+202A) | |
| Right-to-left embedding (U+202B) | |
| Pop directional formatting (U+202C) | |
| So in java, to embed a RTL language like Arabic in an LTR language like English, you would do |
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
| #####Logcat Colors for IntelliJ Darcula Theme ([original post](http://stackoverflow.com/questions/19933731/colored-logcat-in-android-studio-by-colorpid)) | |
| - Preferences -> Editor -> Android Logcat | |
| - "Save As" scheme | |
| - Uncheck "Use inherited attributes" option | |
| - Edit foreground color with the following | |
| ``` | |
| Debug : #E5AD06 | |
| Info : #8AF990 |
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
| import android.os.Environment; | |
| import android.support.annotation.NonNull; | |
| import java.io.File; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.concurrent.TimeUnit; |
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
| class VideoDownloader extends AsyncTask<Void, Long, Boolean> { | |
| @Override | |
| protected void onPreExecute() { | |
| super.onPreExecute(); | |
| } | |
| @Override | |
| protected Boolean doInBackground(Void... params) { |
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
| As Dave Webb mentions, the Android Developer Blog has an article that covers this. Their preferred solution is to track app installs rather than devices, and that will work well for most use cases. The blog post will show you the necessary code to make that work, and I recommend you check it out. | |
| However, the blog post goes on to discuss solutions if you need a device identifier rather than an app installation identifier. I spoke with someone at Google to get some additional clarification on a few items in the event that you need to do so. Here's what I discovered about device identifiers that's NOT mentioned in the aforementioned blog post: | |
| ANDROID_ID is the preferred device identifier. ANDROID_ID is perfectly reliable on versions of Android <=2.1 or >=2.3. Only 2.2 has the problems mentioned in the post. | |
| Several devices by several manufacturers are affected by the ANDROID_ID bug in 2.2. | |
| As far as I've been able to determine, all affected devices have the same ANDROID_ID, which is 9774d56d682e549c. Which 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
| There is a work-around to get the Mac address in Android 6.0. | |
| First you need to add Internet user permission. | |
| <uses-permission android:name="android.permission.INTERNET" /> | |
| Then you can find the mac over the NetworkInterfaces API. | |
| public static String getMacAddr() { | |
| try { | |
| List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces()); |
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
| [Desktop Entry] | |
| Encoding=UTF-8 | |
| Name=Postman | |
| Exec=postman | |
| Icon=/opt/Postman/resources/app/assets/icon.png | |
| Terminal=false | |
| Type=Application | |
| Categories=Development; |
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
| CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams(); | |
| AppBarLayout.Behavior behavior = new AppBarLayout.Behavior(); | |
| behavior.setDragCallback(new AppBarLayout.Behavior.DragCallback() { | |
| @Override | |
| public boolean canDrag(@NonNull AppBarLayout appBarLayout) { | |
| return false; | |
| } | |
| }); | |
| params.setBehavior(behavior); |