android.os.FileUriExposedException: exposed beyond app through ClipData.Item.getUri()

 Process: com.example.espl.nivedhfieldworker, PID: 31238
    android.os.FileUriExposedException: file:///storage/emulated/0/.NivedhFieldWorker/1569647128471.jpg exposed beyond app through ClipData.Item.getUri()
        at android.os.StrictMode.onFileUriExposed(StrictMode.java:1993)
        at android.net.Uri.checkFileUriExposed(Uri.java:2379)
        at android.content.ClipData.prepareToLeaveProcess(ClipData.java:963)
        at android.content.Intent.prepareToLeaveProcess(Intent.java:10227)
        at android.content.Intent.prepareToLeaveProcess(Intent.java:10212)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1736)
        at android.app.Activity.startActivityForResult(Activity.java:4590)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
        at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:234)
        at androidx.fragment.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:796)
        at androidx.fragment.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:933)
        at androidx.fragment.app.Fragment.startActivityForResult(Fragment.java:1197)
        at androidx.fragment.app.Fragment.startActivityForResult(Fragment.java:1185)
        at com.example.espl.nivedhfieldworker.photo_capture.PhotoCaptureFragment.openBackCamera(PhotoCaptureFragment.kt:587)
        at com.example.espl.nivedhfieldworker.photo_capture.PhotoCaptureFragment.access$openBackCamera(PhotoCaptureFragment.kt:61)
        at com.example.espl.nivedhfieldworker.photo_capture.PhotoCaptureFragment$onCreateView$1.onClick(PhotoCaptureFragment.kt:142)
        at android.view.View.performClick(View.java:6600)
        at android.view.View.performClickInternal(View.java:6577)
        at android.view.View.access$3100(View.java:781)
        at android.view.View$PerformClick.run(View.java:25912)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6912)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)

android room update query example

@Query("UPDATE inwardattendenceob SET url_local=:filePath WHERE Carton_Id =:carton_id")
    fun updateCartonInwardImageFilepath(filePath:String,carton_id:String)

'App not Installed' Error on Android

Photo_missing
For me, On Android 9 (API 28), disabling Google Play Protect from play store app worked the trick, and i was able to get rid of the App not Installed error.

Follow steps to disable play protect and then install APK/App:
To disable Google Play Protect.
1. Open "Play Store" application => 2. tap on Menu button => 3. select "Play Protect" option => 4. Disable the options "Scan device for security threats".

shortcut to convert lowercase to uppercase in android studio

https://stackoverflow.com/questions/25494740/is-there-a-shortcut-on-android-studio-to-convert-a-text-to-uppercase

Using edit menu item:
Select the text, then go to Edit → Toggle Case (Ctrl+Shift+U on Windows).

Ubuntu:
You need to keep Caps Lock on while using this shortcut.

I could not get the shortcut Ctrl+Shift+U to work in Android Studio on Ubuntu 14.04 until I turned on Caps Lock.

shortcut on Mac:
The IntelliJ shortcut is evidently Ctrl+Shift+U (Command+Shift+U on Mac) and should work since Android Studio is based off of it.

on Windows:
Andriod studio shortcut Ctrl+Shift+U on Windows.
So If above shortcut not work then you  kept CAPS LOCK ON and should try with CTRL+SHIFT+U and its worked perfectly.

androidx.fragment.app.fragmentstatepageradapter deprecated

https://developer.android.com/reference/androidx/fragment/app/FragmentStatePagerAdapter.html#FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager)

Recently the androidx.fragment.app.FragmentManager is deprecated
It is not deprecated at the present time. For example, it is not marked as deprecated in the documentation.

'FragmentStatePagerAdapter(androidx.fragment.app.FragmentManager)' is deprecated
The single-parameter FragmentStatePagerAdapter constructor is deprecated. However, if you read the documentation for that constructor, you will find:
This constructor is deprecated.
use FragmentStatePagerAdapter(FragmentManager, int) with BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT

So, replace FragmentStatePagerAdapter(fm) with FragmentStatePagerAdapter(fm, FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT), to retain the functionality from the original one-parameter constructor.

Using 'getString' to get device identifiers is not recommended

Kotlin code:
@JvmStatic
    val udid: String?
        get() {
            try {
                return Settings.Secure.getString(MyApplication.get().contentResolver, Settings.Secure.ANDROID_ID)
            } catch (e: Exception) {
                e.fillInStackTrace()
            }

            return null

        }

Android Java code:
String deviceID = Settings.Secure.getString(getApplicationContext().getContentResolver(),
        Settings.Secure.ANDROID_ID);

Best References:
https://stackoverflow.com/questions/47691310/why-is-using-getstring-to-get-device-identifiers-not-recommended
https://developer.android.com/training/articles/user-data-ids.html

Cleartext Http Traffic not Permitted Android 9

Android Studio Error Log: java.io.IOException: Cleartext HTTP traffic to my_IP/domain not permitted

2019-09-06 12:20:29.050 22531-22531/com.geekscompete.gate_isro_cs.ugc_net_preparation E/VolleyError:: ::com.android.volley.NoConnectionError: java.io.IOException: Cleartext HTTP traffic to http://geekscompete.com/ not permitted

Reason for this error:
According to Network security configuration - Opt out of cleartext traffic
Note: The guidance in this section applies only to apps that target Android 8.1 (API level 27) or lower. Starting with Android 9 (API level 28), cleartext support is disabled by default. Network security configuration also suggest to ensure that all connections to your domain are always done over HTTPS to protect sensitive traffic from hostile networks.

You have to create a new file in your xml folder, file named network_security_config.xml.
res/xml/network_security_config.xml:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">yourdomain.com</domain>
        <domain includeSubdomains="true">geekscompete.com</domain>
        <domain includeSubdomains="true">geekscompete.blogspot.com</domain>
    </domain-config>
</network-security-config>

This config will now allow clear traffic to your specified domains after you . Make sure that you have set android:networkSecurityConfig="@xml/network_security_config" in the application tag of your AndroidManifest.xml. The content of your config file should contain all URLs which requests clear traffic without encryption. As shown in below code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.yourappname">
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name=".MainApplication"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:allowBackup="false"
        android:supportsRtl="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:theme="@style/AppTheme">
    </application>
</manifest>


Related Articles: 


java.util.concurrent.TimeoutException android.os.BinderProxy.finalize() timed out after 10 seconds

Fatal Exception: java.util.concurrent.TimeoutException
android.os.BinderProxy.finalize() timed out after 10 seconds
android.os.BinderProxy.destroy (BinderProxy.java)
android.os.BinderProxy.finalize (BinderProxy.java:540)
java.lang.Daemons$FinalizerDaemon.doFinalize (Daemons.java:191)
java.lang.Daemons$FinalizerDaemon.run (Daemons.java:174)
java.lang.Thread.run (Thread.java:818)

android.content.res.resources$notfoundexception: vector drawable

03-11 16:46:57.893 25554-25554/com.elitech.offers.coupons.deals E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.elitech.offers.coupons.deals, PID: 25554
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.elitech.offers.coupons.deals/com.elitech.offers.coupons.deals.cityselection.CityListActivity}: android.view.InflateException: Binary XML file line #150: Error inflating class TextView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
        at android.app.ActivityThread.access$800(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:5333)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #150: Error inflating class TextView
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at io.github.inflationx.viewpump.ViewPumpLayoutInflater.inflate(ViewPumpLayoutInflater.java:55)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.elitech.offers.coupons.deals.cityselection.CityListActivity.onCreate(CityListActivity.java:107)
        at android.app.Activity.performCreate(Activity.java:5343)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
        at android.app.ActivityThread.access$800(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:5333)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_search_loc.xml from drawable resource ID #0x7f070169
        at android.content.res.Resources.loadDrawable(Resources.java:2170)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
        at android.widget.TextView.<init>(TextView.java:841)
        at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:87)
        at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:83)
        at android.support.v7.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:177)
        at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:102)
        at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
        at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
        at io.github.inflationx.viewpump.ViewPumpLayoutInflater$WrapperFactory2ViewCreator.onCreateView(ViewPumpLayoutInflater.java:367)
        at io.github.inflationx.viewpump.FallbackViewCreationInterceptor.intercept(FallbackViewCreationInterceptor.java:11)
        at io.github.inflationx.viewpump.InterceptorChain.proceed(InterceptorChain.java:37)
        at io.github.inflationx.calligraphy3.CalligraphyInterceptor.intercept(CalligraphyInterceptor.java:18)
        at io.github.inflationx.viewpump.InterceptorChain.proceed(InterceptorChain.java:37)
        at io.github.inflationx.viewpump.ViewPump.inflate(ViewPump.java:49)
        at io.github.inflationx.viewpump.ViewPumpLayoutInflater$WrapperFactory2.onCreateView(ViewPumpLayoutInflater.java:348)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at io.github.inflationx.viewpump.ViewPumpLayoutInflater.inflate(ViewPumpLayoutInflater.java:55)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.elitech.offers.coupons.deals.cityselection.CityListActivity.onCreate(CityListActivity.java:107)
        at android.app.Activity.performCreate(Activity.java:5343)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
        at android.app.ActivityThread.access$800(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:5333)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)



        SOL 1:
     
        static {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        }

        Not helped above soution::

        SOL 2: Helped is to set the vector drawable programetically:
         tv_my_current_location.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_search_loc,0, 0, 0);

E/WindowManager: android.view.WindowLeaked: Activity

10-13 16:00:29.760 27725-27725/com.example.DemoApp E/WindowManager: android.view.WindowLeaked: Activity com.example.DemoApp.V2.DealofTheDayActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{65f438d V.E...... R.....I. 0,0-1080,1920} that was originally added here
        at android.view.ViewRootImpl.<init>(ViewRootImpl.java:373)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:302)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:86)
        at android.app.Dialog.show(Dialog.java:322)
        at com.example.DemoApp.BaseActivity$4.onResourceReady(BaseActivity.java:754)
        at com.example.DemoApp.BaseActivity$4.onResourceReady(BaseActivity.java:723)
        at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:568)
        at com.bumptech.glide.request.SingleRequest.onResourceReady(SingleRequest.java:530)
        at com.bumptech.glide.load.engine.EngineJob.handleResultOnMainThread(EngineJob.java:218)
        at com.bumptech.glide.load.engine.EngineJob$MainThreadCallback.handleMessage(EngineJob.java:324)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5604)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)

android.content.res.Resources$NotFoundException: File res/drawable/try_angle.xml from drawable resource ID

01-29 13:10:13.126 1634-1634/com.elitech.offers.coupons.deals W/System.err: android.content.res.Resources$NotFoundException: File res/drawable/try_angle.xml from drawable resource ID #0x7f0701c6
01-29 13:10:13.130 1634-1634/me.me2.com.myapp W/System.err:     at android.content.res.Resources.loadDrawable(Resources.java:2170)
01-29 13:10:13.130 1634-1634/me.me2.com.myapp W/System.err:     at android.content.res.Resources.getDrawable(Resources.java:710)
01-29 13:10:13.130 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:465)
01-29 13:10:13.130 1634-1634/me.me2.com.myapp W/System.err:     at me.me2.com.myapp.V2.HomeRecyclerViewAdapter.onBindViewHolder(HomeRecyclerViewAdapter.java:1055)
01-29 13:10:13.130 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3875)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3639)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1877)
01-29 13:10:13.131 1634-1634/me.me2.com.myapp W/System.err:     at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:407)
01-29 13:10:13.132 1634-1634/me.me2.com.myapp W/System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:591)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.view.Choreographer.doFrame(Choreographer.java:559)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.os.Handler.handleCallback(Handler.java:808)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:103)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.os.Looper.loop(Looper.java:193)
01-29 13:10:13.134 1634-1634/me.me2.com.myapp W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5333)
01-29 13:10:13.135 1634-1634/me.me2.com.myapp W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
01-29 13:10:13.135 1634-1634/me.me2.com.myapp W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
01-29 13:10:13.135 1634-1634/me.me2.com.myapp W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
01-29 13:10:13.137 1634-1634/me.me2.com.myapp W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
01-29 13:10:13.137 1634-1634/me.me2.com.myapp W/System.err:     at dalvik.system.NativeStart.main(Native Method)
01-29 13:10:13.137 1634-1634/me.me2.com.myapp W/System.err: Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector
01-29 13:10:13.138 1634-1634/me.me2.com.myapp W/System.err:     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
01-29 13:10:13.138 1634-1634/me.me2.com.myapp W/System.err:     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
01-29 13:10:13.138 1634-1634/me.me2.com.myapp W/System.err:     at android.content.res.Resources.loadDrawable(Resources.java:2166)
01-29 13:10:13.138 1634-1634/me.me2.com.myapp W/System.err:  ... 30 more

Popular Posts