Wednesday, November 29, 2017

Wifi debugging in Android Studio

Intellij and Android Studio plugin are created to quickly connect your device over wifi to connect to install, run and debugging without using USB connected. 

Here are steps to install plugin to Android Studio

 > Click on Android Studio from top right corner

> Click on Preferences, Opens up new window manager


> Click on Plugins > Click on Browse repositories search as ADB wifi

> Tap on install button, once install's successfully, it show up new icon for Wifi ADB.

> Your phone will get detected and get's connected over wifi/hotspot and hence now you may disconnect USB.

>It will save our time in irregular connection and also remedy for short length USB cable. 

Sunday, November 19, 2017

Thursday, November 16, 2017

FileProvider in Android Nougat

FileProvider is a special sub-class of ContentProvider class helps in secure sharing of files associated with an app by creating a content:// Uri for a file instead of a file ://Uri

A content Uri allows you to grant read and write access using temporary access permission. When you create an intent containing a content URI, in order to send the content URI to client app, you can also call intent.setFlags() to add permissions. This permissions are available to client app as long as the stack for a receiving Activity is active. For an intent going to a service , the permissions are available as long as the service is running


 Defining a FileProvider

Since the default functionality of FileProvider includes content uri generation for the file, you don't need to define a subclass in code. Instead you can include a fileprovider in your app by specifying it entirely in XML. 


<manifest>
    ...
    <application>
        ...
        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.mydomain.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            ...
        </provider>
        ...
    </application>
</manifest>
If you want to override any of the default behaviour of FileProvider methods, extend the FileProvider class and use the fully qualified class name in the
android:name attribute of the <provider> element

android:authorities > set to a URI authority based on domain you control;
if you use the same authorities for different apps, while installing it may through an exception to uninstall existing app which has same authority

android:exported > set to false, File provider does not need to be public

android:grantUriPermissions > set to true, to allow you to temporary access to files.



Specifying Available Files

nt A file provider can only generate content URI for files in directories that you specify beforhand
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="my_images" path="images/"/>
    ...</paths>