<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7471395497203692205</id><updated>2024-08-30T04:48:28.301+05:30</updated><category term="Buttons"/><category term="Activity"/><category term="Intent"/><category term="TextView"/><category term="Application"/><category term="ArrayList"/><category term="Dialog"/><category term="EditText"/><category term="List view"/><category term="Toast"/><category term="context"/><category term="Alert Dialog"/><category term="BaseAdapter"/><category term="File"/><category term="ImageView"/><category term="Seekbar"/><category term="Uri"/><category term="cursor"/><category term="ArrayAdapter"/><category term="AsyncTask"/><category term="Handler"/><category term="HttpEntity"/><category term="HttpPost"/><category term="HttpResponse"/><category term="InputStream"/><category term="Sha1"/><category term="StringBuilder"/><category term="Thread"/><category term="Animation"/><category term="BufferedReader"/><category term="Canvas"/><category term="Color"/><category term="FCM"/><category term="FileInputStream"/><category term="Firebase"/><category term="Gallery"/><category term="GalleryImage"/><category term="Hashmap"/><category term="HttpClient"/><category term="Imagebutton"/><category term="InputStreamReader"/><category term="Internet"/><category term="LayoutInflater"/><category term="MenuInflater"/><category term="MessageDigest"/><category term="NameValuePair"/><category term="OS/kernel"/><category term="Paint"/><category term="Progressbar"/><category term="Runnable"/><category term="SharedPreferences"/><category term="StringBuffer"/><category term="THREAD_POOL_EXECUTOR"/><category term="Theme"/><category term="UrlEncodedFormEntity"/><category term="gradient"/><category term="AES"/><category term="Android 4.0"/><category term="Android Things"/><category term="Animation FadeIn"/><category term="Animation FadeOut"/><category term="AnimationUtils"/><category term="Array"/><category term="Base64"/><category term="Bitmap"/><category term="Bundle"/><category term="Buttonbackground"/><category term="ByteArrayBody"/><category term="Calender"/><category term="ChaeSequence"/><category term="Cipher"/><category term="Collections"/><category term="Color.argb"/><category term="ColorPickerDialog"/><category term="Comparator"/><category term="ConnectivityManager"/><category term="Contact list"/><category term="ContactsContract"/><category term="CountDownTimer"/><category term="CursorAdapter"/><category term="DatePickerDialog"/><category term="DecimalFormat"/><category term="Decompress"/><category term="DefaultHttpClient"/><category term="DialogFragment"/><category term="DisplayMetrics"/><category term="Domparsing"/><category term="DrawBarChart"/><category term="DrawPieChart"/><category term="File provider"/><category term="FileOutputStream"/><category term="FilenameFilter"/><category term="GCM"/><category term="Geocoder"/><category term="GridLayoutManager"/><category term="HttpGet"/><category term="HttpTransportSE"/><category term="HttpUriRequest"/><category term="ImageBytes"/><category term="Images"/><category term="IoT"/><category term="ItemAnimator"/><category term="JSONArray"/><category term="JSONObject"/><category term="KeySpec"/><category term="LinearLayoutManager"/><category term="LocationListener"/><category term="LocationManager"/><category term="Matcher"/><category term="Media. ResolveInfo"/><category term="MediaPlayer"/><category term="MediaStore"/><category term="Message"/><category term="MultipartEntity"/><category term="Multiple permission"/><category term="NetworkInfo"/><category term="Notification"/><category term="NumberFormat"/><category term="OutputStream"/><category term="PERMISSION_GRANTED"/><category term="POWER_SERVICE"/><category term="PackageInfo"/><category term="PackageManager"/><category term="Pattern"/><category term="Piechart"/><category term="PowerManager"/><category term="Preferencesceen"/><category term="Process"/><category term="ProcessBuilder"/><category term="ProgressDialog"/><category term="PropertyInfo"/><category term="PushNotification"/><category term="Random"/><category term="RecyclerView"/><category term="RelativeLayout"/><category term="Rotate"/><category term="Rotate center"/><category term="Rotate corner"/><category term="SecretKey"/><category term="SecretKeyFactory"/><category term="SimpleCursorAdapter"/><category term="SoapObject"/><category term="SoapPrimitive"/><category term="SoapSerializationEnvelope"/><category term="Spinner layout"/><category term="StaggeredGridLayoutManager"/><category term="StringBody"/><category term="Tab Layouts"/><category term="TextToSpeech"/><category term="TextWatcher"/><category term="Time"/><category term="TimePickerDialog"/><category term="TypeArray"/><category term="URLConnection"/><category term="View"/><category term="ViewHolder"/><category term="Weave"/><category term="Web service"/><category term="ZipEntry"/><category term="ZipInputStream"/><category term="alpha"/><category term="android 7.0"/><category term="android:state_active"/><category term="android:state_focused"/><category term="android:state_pressed"/><category term="android:state_selected"/><category term="battery"/><category term="broadcastreceiver"/><category term="checkSelfPermission"/><category term="comparison"/><category term="corners"/><category term="declare-stylable"/><category term="galleryItemBackground"/><category term="isDirectory"/><category term="item"/><category term="menu"/><category term="messaging"/><category term="nougat"/><category term="onProgressUpdate"/><category term="onRequestPermissionsResult"/><category term="padding"/><category term="permission"/><category term="provider"/><category term="query"/><category term="requestPermissions"/><category term="runOnUiThread"/><category term="runtime permission"/><category term="services"/><category term="shouldShowRequestPermissionRationale"/><category term="stroke"/><category term="website"/><category term="webview"/><title type='text'>ANDROID DEVELOPMENT RESOURCES</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>76</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-9032129405488659593</id><published>2016-12-23T12:35:00.000+05:30</published><updated>2016-12-23T12:39:39.200+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android Things"/><category scheme="http://www.blogger.com/atom/ns#" term="IoT"/><category scheme="http://www.blogger.com/atom/ns#" term="Weave"/><title type='text'>Google internet of thing plateform for android named &quot;Android Things and Weave&quot;</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;Google has announced a new platform to work with Android IoT applications to smartly connected devices.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;For more update please refer&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://android-developers.blogspot.com/2016/12/announcing-googles-new-internet-of-things-platform-with-weave-and-android-things.html&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Announcing updates to Google’s Internet of Things platform: Android Things and Weave&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTRnsEylk2DC4zD1wEbLHeSzYQx7LxmTTU_jv29eDm6ZbpdguQW5aLjI024_xd_oHz5HAE06noeCLRFAds22sbHRVbFoSk3GiH3rnZyf9uOMMXXHTkFM0HIKHv1OmGdzANvvpOr6z8KP9S/s1600/weave_logo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTRnsEylk2DC4zD1wEbLHeSzYQx7LxmTTU_jv29eDm6ZbpdguQW5aLjI024_xd_oHz5HAE06noeCLRFAds22sbHRVbFoSk3GiH3rnZyf9uOMMXXHTkFM0HIKHv1OmGdzANvvpOr6z8KP9S/s1600/weave_logo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;To get started, check out&lt;/b&gt;&lt;/span&gt; &lt;a href=&quot;https://developers.google.com/iot&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Google&#39;s IoT developer site&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;, or go directly to the&lt;/b&gt;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;https://developers.android.com/things&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Android Things&lt;/span&gt;&lt;/a&gt;, &lt;a href=&quot;https://developers.google.com/weave&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Weave&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;,&lt;/span&gt; &lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;and&lt;/b&gt;&lt;/span&gt; &lt;a href=&quot;https://cloud.google.com/&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Google Cloud Platform&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt; sites for documentation and code samples. You can also join&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;a href=&quot;https://g.co/iotdev&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Google&#39;s IoT Developers Community&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; &lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;on Google+ to get the latest updates and share and discuss ideas with other developers.&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/9032129405488659593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/12/google-internet-of-thing-plateform-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/9032129405488659593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/9032129405488659593'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/12/google-internet-of-thing-plateform-for.html' title='Google internet of thing plateform for android named &quot;Android Things and Weave&quot;'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTRnsEylk2DC4zD1wEbLHeSzYQx7LxmTTU_jv29eDm6ZbpdguQW5aLjI024_xd_oHz5HAE06noeCLRFAds22sbHRVbFoSk3GiH3rnZyf9uOMMXXHTkFM0HIKHv1OmGdzANvvpOr6z8KP9S/s72-c/weave_logo.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-3488260975373873310</id><published>2016-10-14T01:15:00.000+05:30</published><updated>2016-10-14T01:15:19.406+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Images"/><category scheme="http://www.blogger.com/atom/ns#" term="Intent"/><category scheme="http://www.blogger.com/atom/ns#" term="Media. ResolveInfo"/><category scheme="http://www.blogger.com/atom/ns#" term="MediaStore"/><category scheme="http://www.blogger.com/atom/ns#" term="PackageManager"/><category scheme="http://www.blogger.com/atom/ns#" term="Toast"/><title type='text'>Pick images from default gallery intent</title><content type='html'>&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Pick image from default gallery images... from android&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
final PackageManager packageManager = getPackageManager();&lt;br /&gt;Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);&lt;/b&gt;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;List&amp;lt;ResolveInfo&amp;gt; list = packageManager.queryIntentActivities(intent,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PackageManager.MATCH_DEFAULT_ONLY);&lt;br /&gt;if (list.size() &amp;gt; 0) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;startActivityForResult(intent, PICK_IMAGE_REQUEST);&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Toast.makeText(UserProfileEditActivity.this, &quot;No app can perform this action&quot;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Toast.LENGTH_LONG).show();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return;&lt;br /&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/3488260975373873310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/10/pick-images-from-default-gallery-intent.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3488260975373873310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3488260975373873310'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/10/pick-images-from-default-gallery-intent.html' title='Pick images from default gallery intent'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-5422119754407922022</id><published>2016-09-25T23:57:00.001+05:30</published><updated>2016-09-25T23:57:57.440+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Alert Dialog"/><category scheme="http://www.blogger.com/atom/ns#" term="checkSelfPermission"/><category scheme="http://www.blogger.com/atom/ns#" term="Hashmap"/><category scheme="http://www.blogger.com/atom/ns#" term="Multiple permission"/><category scheme="http://www.blogger.com/atom/ns#" term="onRequestPermissionsResult"/><category scheme="http://www.blogger.com/atom/ns#" term="permission"/><category scheme="http://www.blogger.com/atom/ns#" term="PERMISSION_GRANTED"/><category scheme="http://www.blogger.com/atom/ns#" term="requestPermissions"/><category scheme="http://www.blogger.com/atom/ns#" term="runtime permission"/><category scheme="http://www.blogger.com/atom/ns#" term="shouldShowRequestPermissionRationale"/><title type='text'>Checking multiple run time permission for marshmellow and above in android </title><content type='html'>Hello friend., Here i am posting tutorial for granting multiple permission with common code.. You need to add this code once and check permission run time.&lt;br /&gt;
&lt;br /&gt;
Make one class in with common methods can be added in it. I call it CM as common methods. Add the following code in the common code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;CM.java&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;public static void showMessageOKCancel(Activity context, String message, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DialogInterface.OnClickListener okListener) {&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new AlertDialog.Builder(context)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.setMessage(message)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.setPositiveButton(&quot;OK&quot;, okListener)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.setNegativeButton(&quot;Cancel&quot;, null)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.create()&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.show();&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;br /&gt;&lt;br /&gt;public static void applyMarshmallowPermission(&lt;/b&gt;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Activity context, String Permission[], String[] strPermissionMessage,&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final int RequestCode, OnPermissionAlreadyGrant callBackPermission) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final List&amp;lt;String&amp;gt; permissionsList = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; List&amp;lt;String&amp;gt; permissionsNeeded = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; Permission.length; i++) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!addPermission(context, permissionsList, Permission[i])) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; permissionsNeeded.add(strPermissionMessage[i]);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (permissionsList.size() &amp;gt; 0) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (permissionsNeeded.size() &amp;gt; 0) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Need Rationale&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String message = &quot;You need to grant access to &quot; + permissionsNeeded.get(0);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i = 1; i &amp;lt; permissionsNeeded.size(); i++)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;message = message + &quot;, &quot; + permissionsNeeded.get(i);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; showMessageOKCancel(context, message,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new DialogInterface.OnClickListener() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onClick(DialogInterface dialog, int which) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ActivityCompat.requestPermissions(context, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; permissionsList.toArray(new &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String[permissionsList.size()]),&amp;nbsp;RequestCode);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ActivityCompat.requestPermissions(context, permissionsList.toArray(new &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String[permissionsList.size()]), &amp;nbsp;RequestCode);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (callBackPermission != null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; callBackPermission.onPermssionAlreadyGranted();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private static boolean addPermission(Activity&amp;nbsp;context,&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;List&amp;lt;String&amp;gt; permissionsList, String permission) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; permissionsList.add(permission);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Check for Rationale Option&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (ActivityCompat.shouldShowRequestPermissionRationale(context, permission)) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return true;&lt;br /&gt;&lt;br /&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;public static int checkNeverAskAgainList(Activity&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context, String[] permissionsList) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int deniedList = 0;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (String strPermission : permissionsList) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;boolean isRational = ActivityCompat.shouldShowRequestPermissionRationale(context, strPermission);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (isRational) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; deniedList++;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp;return deniedList;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public static void goToSettings(Activity context) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Intent myAppSettings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse(&quot;package:&quot; + context.getPackageName()));&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; myAppSettings.addCategory(Intent.CATEGORY_DEFAULT);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; myAppSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; context.startActivity(myAppSettings);&lt;br /&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This methods are used to check for permissions that user has to allow or user will go to setting and allow the permission that our app needs.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now how to use this for multiple permission grant in your activity using this methods.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;Add this in your activity when you need to check the permissions&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;//Mention list of permissions that are needed in your activity&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;String strPermissoinList[] = new String[]{android.Manifest.permission.READ_PHONE_STATE, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android.Manifest.permission.GET_ACCOUNTS};&lt;/span&gt;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;// Description to be shown to user for particular permission if user denied once.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;String strPermissionMessage[] = new String[]{&quot;Phone State&quot;, &quot;Google+ Account&quot;};&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;// Request code to be used when permission is received from user&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;public static final int PERMISSION_MULTIPLE_GRANT_CODE = 1001;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;br /&gt;public void buttonClick(View view) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CM.applyMarshmallowPermission(MainActivity.this, strPermissoinList, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;strPermissionMessage, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PERMISSION_MULTIPLE_GRANT_CODE,&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new OnPermissionAlreadyGrant() {&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onPermssionAlreadyGranted() {&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if you have already granted or sdk version is below marshmellow&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Toast.makeText(MainActivity.this, &quot;You have allowed all permission. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;applyMarshmallowPermission : &quot; + &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CM.getDeviceId(MainActivity.this), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Toast.LENGTH_SHORT).show();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
Now add the following lines in the&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;onRequestPermissionsResult&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;code.&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;@Override&lt;br /&gt;public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;switch (requestCode) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case PERMISSION_MULTIPLE_GRANT_CODE:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Map&amp;lt;String, Integer&amp;gt; perms = new HashMap&amp;lt;String, Integer&amp;gt;();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Initial&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; perms.put(android.Manifest.permission.READ_PHONE_STATE, PackageManager.PERMISSION_GRANTED);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; perms.put(android.Manifest.permission.GET_ACCOUNTS, PackageManager.PERMISSION_GRANTED);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Fill with results&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; permissions.length; i++)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; perms.put(permissions[i], grantResults[i]);&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Check for&amp;nbsp;READ_PHONE_STATE&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (perms.get(android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;&amp;amp; perms.get(android.Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Toast.makeText(this, &quot;You have allowed all permission. onRequestPermissionsResult :: &quot; + CM.getDeviceId(MainActivity.this), Toast.LENGTH_SHORT)&lt;br /&gt; .show();&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} else {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int countBlock = CM.checkNeverAskAgainList(this, strPermissoinList);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (countBlock &amp;gt; 0) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Permission Denied&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Toast.makeText(this, &quot;You denied the permission&quot;, Toast.LENGTH_SHORT)&lt;br /&gt; .show();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CM.showMessageOKCancel(MainActivity.this, &quot;Go to setting and give permission&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new DialogInterface.OnClickListener() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onClick(DialogInterface dialog, int which) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CM.goToSettings(MainActivity.this);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; default:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;super.onRequestPermissionsResult(requestCode, permissions, grantResults);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Finally the callback interface that you need to define in your code is below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;public interface OnPermissionAlreadyGrant {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;void onPermssionAlreadyGranted();&lt;br /&gt;}&lt;/span&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/5422119754407922022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/09/checking-multiple-run-time-permission.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/5422119754407922022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/5422119754407922022'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/09/checking-multiple-run-time-permission.html' title='Checking multiple run time permission for marshmellow and above in android '/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-7885880080056149833</id><published>2016-09-25T22:46:00.001+05:30</published><updated>2016-09-25T22:49:23.380+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android 7.0"/><category scheme="http://www.blogger.com/atom/ns#" term="File provider"/><category scheme="http://www.blogger.com/atom/ns#" term="nougat"/><category scheme="http://www.blogger.com/atom/ns#" term="provider"/><category scheme="http://www.blogger.com/atom/ns#" term="Uri"/><title type='text'>file:// scheme is now not allowed to be attached with Intent on targetSdkVersion 24 (Android Nougat). What todo?</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en&lt;br /&gt;&lt;br /&gt;Android Nougat is almost be publicly released. And as an Android developer, we need to prepare ourself to adjust &lt;b&gt;targetSdkVersion&lt;/b&gt; to the latest one, &lt;b&gt;24,&lt;/b&gt; to let everything works perfectly on the newest release of Android.&lt;br /&gt;&lt;br /&gt;And as always, everytime we adjust targetSdkVersion, we need to check and make sure that every single part of our code works perfectly fine. If you just simply change the number, I could say that your application is taking a high risk of crashing or malfunction. In this case, when you change your app&#39;s targetSdkVersion to 24, we need to check that every single function works flawlessly on Android Nougat (24).&lt;br /&gt;&lt;br /&gt;And this is one of the checklist you need to mark done before releasing your new version. There is one big security change on Android N like quoted below:&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;br /&gt;Passing file:// URIs outside the package domain may leave the receiver with an unaccessible path. Therefore, attempts to pass a file:// URI trigger a FileUriExposedException. The recommended way to share the content of a private file is using the &lt;a href=&quot;https://developer.android.com/reference/android/support/v4/content/FileProvider.html&quot;&gt;FileProvider&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Summarily, file:// is not allowed to attach with Intent anymore or it will throw FileUriExposedException which may cause your app crash immediately called.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;This blog will talk about this issue and also about the solution how to make it work on Android N.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Real example with a crashing problem&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You may be curious which situation that can really cause the problem. So to make it be easy to you all, let me show you a real usage example that causes crashing. The easiest example is the way we take a photo through Intent with ACTION_IMAGE_CAPTURE type. Previously we just pass the target file path with file://  format as an Intent extra which works fine on Android Pre-N but will just simply crash on Android N and above.&lt;br /&gt;
&lt;br /&gt;
If you are running the code with targetsdkversion set to 23. But this will give you an following exception when you set targetsdkversion to 24.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;FATAL EXCEPTION: main Process: com.inthecheesefactory.lab.intent_fileprovider, PID: 28905&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;android.os.FileUriExposedException: file:///storage/emulated/0/DCIM/Camera/IMG_25092016.jpg exposed beyond app through ClipData.Item.getUri()&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;at android.net.Uri.checkFileUriExposed(Uri.java:2346)&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832) ...&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;The reason is quite obvious. file:// is not allowed as an attached URI in Intent or FileUriExposedException would be thrown.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;And this is a big issue that you have to make sure that all code related to this case has already been fixed before releasing a new version with targetSdkVersion 24 or your app may crash on some of your user&#39;s device.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-size: large;&quot;&gt;Why nougat does not allow passing file:// with intent any more?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;You may be curious why Android team decide to change this behavior. Actually there is a good reason behind.&lt;br /&gt;&lt;br /&gt;If file path is sent to the target application (Camera app in this case), file will be fully accessed through the Camera app&#39;s process not the sender one.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;img src=&quot;https://inthecheesefactory.com/uploads/source/fileuri/withfile.jpg&quot; /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;But let&#39;s consider thoroughly, actually Camera is launched by our application to take a photo and save as a file on our app&#39;s behalf. So the access right to that file should be our app&#39;s not Camera&#39;s. Every operation did with the file should be done through our application not by Camera app itself.&lt;br /&gt;&lt;br /&gt;And that&#39;s why file:// is now prohibited on targetSdkVersion 24 to force every developer to do this task in the proper way.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-size: large;&quot;&gt;&lt;b&gt;Solution is as below :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;So if file:// is not allowed anymore, which approach should we go for? The answer is we should send the URI through content:// scheme instead which is the URI scheme for Content Provider. In this case, we would like to share an access to a file through our app so FileProvider is needed to be implemented. Flow is now changed like below:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;img src=&quot;https://inthecheesefactory.com/uploads/source/fileuri/withfileprovider.jpg&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;br /&gt;And now, with FileProvider, file operation would be done through our app process like it supposes to be !&lt;br /&gt;&lt;br /&gt;It is quite easy to implement FileProvider on your application. First you need to add a FileProvider&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;lt;provider&amp;gt;&lt;/span&gt; tag in &lt;span style=&quot;color: #cc0000;&quot;&gt;AndroidManifest.xml&lt;/span&gt; under &lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;lt;application&amp;gt;&lt;/span&gt; tag like below:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;AndroidMenifest.xml&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ........&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;application&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ... &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;provider&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:name=&quot;android.support.v4.content.FileProvider&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:authorities=&quot;${applicationId}.provider&quot; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:exported=&quot;false&quot; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:grantUriPermissions=&quot;true&quot;&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;meta-data android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:resource=&quot;@xml/provider_paths&quot;/&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/provider&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/application&amp;gt; &lt;br /&gt;&amp;lt;/manifest&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;And then create a provider_paths.xml file in xml folder under res folder. Folder may be needed to create if it doesn&#39;t exist.&lt;br /&gt;&lt;br /&gt;The content of the file is shown below. It describes that we would like to share access to the External Storage at root folder (path=&quot;.&quot;) with the name external_files.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;res/xml/provider_paths.xml&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;paths xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;external-path name=&quot;external_files&quot; path=&quot;.&quot;/&amp;gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&amp;lt;/paths&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;FileProvider is now declared and be ready to use.&lt;br /&gt;&lt;br /&gt;The last step is to change the line of code below in Activity&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Uri photoURI = Uri.fromFile(createImageFile());&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;to&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Uri photoURI = FileProvider.getUriForFile(MainActivity.this,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BuildConfig.APPLICATION_ID + &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;.provider&quot;, createImageFile());&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You are done, Your code should run in all the previous version with nougat.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/7885880080056149833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/09/file-scheme-is-now-not-allowed-to-be.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/7885880080056149833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/7885880080056149833'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/09/file-scheme-is-now-not-allowed-to-be.html' title='file:// scheme is now not allowed to be attached with Intent on targetSdkVersion 24 (Android Nougat). What todo?'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-8806670376381371590</id><published>2016-09-25T22:43:00.002+05:30</published><updated>2016-10-03T14:42:20.868+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="FCM"/><category scheme="http://www.blogger.com/atom/ns#" term="Firebase"/><category scheme="http://www.blogger.com/atom/ns#" term="Notification"/><category scheme="http://www.blogger.com/atom/ns#" term="PushNotification"/><category scheme="http://www.blogger.com/atom/ns#" term="services"/><title type='text'>Firebase notification if you are creating a new one</title><content type='html'>&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-size: large;&quot;&gt;Add firebase to your application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add Firebase to your app you&#39;ll need a Firebase project and a Firebase configuration file for your app.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Create a Firebase project in the &lt;a href=&quot;https://firebase.google.com/console/&quot;&gt;Firebase console&lt;/a&gt;, if you don&#39;t already have one. If you already have an existing Google project associated with your mobile app, click Import Google Project. Otherwise, click Create New Project.&lt;/li&gt;
&lt;li&gt;Click Add Firebase to your Android app and follow the setup steps. If you&#39;re importing an existing Google project, this may happen automatically and you can just&amp;nbsp;download the config file.&lt;/li&gt;
&lt;li&gt;When prompted, enter your app&#39;s package name. It&#39;s important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.&lt;/li&gt;
&lt;li&gt;At the end, you&#39;ll download a google-services.json file. You can download this file again at any time.&lt;/li&gt;
&lt;li&gt;If you haven&#39;t done so already, copy this into your project&#39;s module folder, typically app/.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;strong style=&quot;box-sizing: inherit; font-family: Roboto, sans-serif; font-size: 14px; margin-top: 0px;&quot;&gt;Note:&lt;/strong&gt;&lt;span style=&quot;box-sizing: inherit; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 14px; margin-bottom: 0px;&quot;&gt;&amp;nbsp;If you have multiple build variants with different package names defined, each app must be added to your project in Firebase console.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-size: large;&quot;&gt;Add the SDK&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;box-sizing: inherit; color: #212121; font-family: Roboto, sans-serif; font-size: 16px; margin-bottom: 16px; margin-top: 16px; padding: 0px;&quot;&gt;
If you would like to integrate the Firebase libraries into one of your own projects, you need to perform a few basic tasks to prepare your Android Studio project. You may have already done this as part of adding Firebase to your app.&lt;/div&gt;
&lt;div style=&quot;box-sizing: inherit; margin-bottom: 16px; margin-top: 16px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;Fir&lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;st, add rules to your root-level&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;build.gradle&lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;file, to include the google-services plugin:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;buildscript &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //....&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;dependencies &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //.....&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classpath&lt;/span&gt;&amp;nbsp;&#39;&lt;span style=&quot;color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;com.google.gms:google-services:3.0.0&lt;/span&gt;&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;Then, in your module Gradle file (usually the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;app/build.gradle&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;, add the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;apply plugin&lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&amp;nbsp;line at the bottom of the file to enable the Gradle plugin:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;apply plugin: &#39;&lt;/span&gt;&lt;span style=&quot;color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;com.android.application&lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //....&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;dependencies&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&amp;nbsp; &amp;nbsp; // ...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;compile&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&#39;com.google.firebase:firebase-core:9.6.0&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;ADD THIS AT THE BOTTOM&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;apply plugin&lt;/span&gt;&amp;nbsp;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&#39;com.google.gms.google-services&#39;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Set Up a Firebase Cloud Messaging Client App on Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;FCM clients require devices running Android 2.3 or higher that also have the Google Play Store app installed, or an emulator running Android 2.3 with Google APIs. Note that you are not limited to deploying your Android apps through Google Play Store.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;Edit your app manifest&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Add the following to your app&#39;s manifest:&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;A service that extends FirebaseMessagingService. This is required if you want to do any message handling beyond receiving notifications on apps in the background. To receive notifications in foregrounded apps, to receive data payload, to send upstream messages, and so on, you must extend this service.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;A service that extends FirebaseInstanceIdService to handle the creation, rotation, and updating of registration tokens. This is required for sending to specific devices or for creating device groups.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;If FCM is critical to the Android app&#39;s function, be sure to set android:minSdkVersion=&quot;8&quot; or higher in the manifest. This ensures that the Android app cannot be installed in an environment in which it could not run properly.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;service&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;.MyFirebaseMessagingService&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.firebase.MESSAGING_EVENT&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;service&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;.MyFirebaseInstanceIDService&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.firebase.INSTANCE_ID_EVENT&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;a href=&quot;https://typicaljava.blogspot.in/2016/09/migrate-gcm-client-app-for-android-to.html&quot;&gt;Check &lt;/a&gt;this for implementing these 2 services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/8806670376381371590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/09/firebase-notification-if-you-are.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/8806670376381371590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/8806670376381371590'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/09/firebase-notification-if-you-are.html' title='Firebase notification if you are creating a new one'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-5162014124838150407</id><published>2016-09-18T22:55:00.001+05:30</published><updated>2016-09-25T00:00:08.510+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="FCM"/><category scheme="http://www.blogger.com/atom/ns#" term="Firebase"/><category scheme="http://www.blogger.com/atom/ns#" term="GCM"/><category scheme="http://www.blogger.com/atom/ns#" term="messaging"/><category scheme="http://www.blogger.com/atom/ns#" term="Sha1"/><title type='text'>Migrate a GCM Client App for Android to Firebase Cloud Messaging</title><content type='html'>&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;Import your GCM project as a Firebase project&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;
&lt;ol style=&quot;box-sizing: inherit; color: #212121; font-family: Roboto, sans-serif; font-size: 16px; line-height: 24px; list-style-position: outside; margin: 0px; padding-left: 40px;&quot;&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
In the Firebase console, select&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Import Google Project&lt;/strong&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
Select your GCM project from the list of existing projects and select&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Add Firebase&lt;/strong&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
In the Firebase welcome screen, select&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Add Firebase to your Android App&lt;/strong&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
Provide your package name and SHA-1, and select&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Add App&lt;/strong&gt;. A new google-services.json file for your Firebase app is downloaded.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
Select&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;Continue&lt;/strong&gt;&amp;nbsp;and follow the detailed instructions for adding the Google Services plugin in Android Studio.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Switch to FCM in the app-level build.gradle&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;BEFORE&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;dependencies &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; compile &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.android.gms:play-services-gcm:8.4.0&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;AFTER&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;dependencies {&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;  compile &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.firebase:firebase-messaging:9.0.0&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Remove the permissions required by GCM&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; line-height: 24px;&quot;&gt;All the permissions required by FCM are now added automatically by library&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot;, courier, monospace;&quot;&gt;BEFORE&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot;, courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;uses-permission&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;android.permission.WAKE_LOCK&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;lt;permission android:name=&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;your-package-name&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;.permission.C2D_MESSAGE&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:protectionLevel=&quot;signature&quot; /&amp;gt;
&amp;lt;uses-permission android:name=&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;your-package-name&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;.permission.C2D_MESSAGE&quot; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;AFTER&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;No permissions&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Remove the receiver from the app manifest&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;box-sizing: inherit; margin-bottom: 16px; margin-top: 16px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;With FCM,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;com.google.android.gms.gcm.GcmReceiver&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp;is added automatically.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: inherit; font-size: 16px; line-height: 24px; margin-bottom: 16px; margin-top: 16px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;AndroidManifest.xml Before&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;receiver&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.android.gms.gcm.GcmReceiver&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:exported&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:permission&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.android.c2dm.permission.SEND&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.android.c2dm.intent.RECEIVE&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;category&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.example.gcm&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/receiver&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;
&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;line-height: 24px; white-space: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;AndroidManifest.xml After&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; line-height: 24px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; line-height: 24px; white-space: normal;&quot;&gt;No receiver&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; line-height: 24px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; line-height: 24px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Migrate your listener service&lt;/b&gt;&lt;/span&gt;

&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;A service extending &lt;span style=&quot;color: #cc0000;&quot;&gt;InstanceIDListenerService &lt;/span&gt;is now required only if you want to access &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;the FCM token.

This is needed if you want to&lt;/span&gt;&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Manage device tokens to send a messages to single device directly, or&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Send messages to device group, or&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Subscribe devices to topics with the server subscription management API.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #212121; line-height: 24px; white-space: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;If you don&#39;t use these features, you can completely remove this service along with client code to initiate the generation of a registration token.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #212121; line-height: 24px; white-space: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;b style=&quot;color: #cc0000; font-family: arial, helvetica, sans-serif; font-size: x-large;&quot;&gt;Update the Android Manifest&lt;/b&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 16px; line-height: 24px; white-space: normal;&quot;&gt;
&lt;/b&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 16px; line-height: 24px; white-space: normal;&quot;&gt;AndroidManifest.xml Before&lt;/b&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;service&lt;/span&gt;
&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;    android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;.MyInstanceIDListenerService&quot;&lt;/span&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android:exported&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;com.google.android.gms.iid.InstanceID&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;b style=&quot;color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;AndroidManifest.xml After&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;

&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;service&lt;/span&gt;
   &lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;.MyInstanceIDListenerService&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   &amp;lt;intent-filter&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;com.google.firebase.INSTANCE_ID_EVENT&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   &amp;lt;/intent-filter&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;/service&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;h3 id=&quot;update_your_instanceidlistenerservice&quot; style=&quot;box-sizing: inherit; font-stretch: normal; line-height: 32px; margin: 32px 0px 16px; overflow: hidden; padding: 0px; text-overflow: ellipsis; white-space: normal;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;Update your InstanceIDListenerService&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; white-space: normal;&quot;&gt;Change&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;MyInstanceIDListenerService &lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; white-space: normal;&quot;&gt;to extend&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;FirebaseInstanceIdService&lt;/span&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; white-space: normal;&quot;&gt;, and update code to listen for token updates and get the token whenever a new token is generated.&lt;/span&gt;

&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;MyInstanceIDListenerService.java Before&lt;/b&gt;&lt;/span&gt;

&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;MyInstanceIDListenerService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;InstanceIDListenerService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #c53929; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;      @Override&lt;/span&gt;
      &lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; onTokenRefresh&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; {&lt;/span&gt;
       &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;// Fetch updated Instance ID token and notify our app&#39;s server of any&lt;/span&gt; 
&lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;         changes (if applicable).&lt;/span&gt;
          &lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; intent &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;RegistrationIntentService&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;);&lt;/span&gt;
          &lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;startService&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;intent&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;);&lt;/span&gt;
      &lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;}&lt;/span&gt;

&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;MyInstanceIDListenerService.java After&lt;/b&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;MyInstanceIDListenerService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;FirebaseInstanceIdService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;/**&lt;/span&gt;
   &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;* Called if InstanceID token is updated. This may occur if the security of&lt;/span&gt;
   &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;* the previous token had been compromised. Note that this is also called&lt;/span&gt;
   &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;* when the InstanceID token is initially generated, so this is where&lt;/span&gt;
   &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;* you retrieve the token.&lt;/span&gt;
&lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   */&lt;/span&gt;
  
&lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   // [START refresh_token]&lt;/span&gt;
  
&lt;span style=&quot;color: #c53929; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   @Override&lt;/span&gt;
&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; onTokenRefresh&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;com&quot; style=&quot;box-sizing: inherit; color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;// Get updated InstanceID token.&lt;/span&gt;
   &lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; refreshedToken &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;FirebaseInstanceId&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;getInstance&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;getToken&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;Log&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;TAG&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;Refreshed token: &quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; refreshedToken&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;);&lt;/span&gt;
   &lt;span style=&quot;color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;// TODO: Implement this method to send any registration to your app&#39;s servers.&lt;/span&gt;
   &lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;sendRegistrationToServer&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;refreshedToken&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;  }&lt;/span&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Remove registration&lt;/b&gt;&lt;/span&gt;

&lt;span style=&quot;color: #212121; font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px; white-space: normal;&quot;&gt;You no longer need to explicitly initiate the generation of a registration token — the library does this automatically. Therefore, you can remove code like the following:&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint notranslate&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; margin-bottom: 16px; margin-top: 16px; overflow-x: auto; padding: 8px; position: relative;&quot; translate=&quot;no&quot;&gt;&lt;code&gt;&lt;span class=&quot;typ&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;  InstanceID&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; instanceID &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;InstanceID&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;getInstance&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; token &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; instanceID&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;getToken&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;gcm_defaultSenderId&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;GoogleCloudMessaging&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;INSTANCE_ID_SCOPE&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #d81b60; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;// [END get_token]&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;Log&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;TAG&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;&quot;GCM Registration Token: &quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt; token&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background: 0px center; box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px; font-stretch: normal; line-height: 1; padding: 0px; word-break: normal;&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;Migrate your GcmListenerService&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: inherit; color: #212121; font-family: Roboto, sans-serif; font-size: 16px; margin-bottom: 16px; margin-top: 16px; padding: 0px;&quot;&gt;
A service extending GcmListenerService is now required&amp;nbsp;&lt;strong style=&quot;box-sizing: inherit;&quot;&gt;only&lt;/strong&gt;&amp;nbsp;for the following use cases:&lt;/div&gt;
&lt;ul style=&quot;box-sizing: inherit; color: #212121; font-family: Roboto, sans-serif; font-size: 16px; list-style-image: initial; list-style-position: outside; margin: 0px; padding-left: 40px;&quot;&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
receiving messages with notification payload while the application is in foreground&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
receiving messages with data payload only&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;box-sizing: inherit; margin: 8px 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: inherit; padding: 0px;&quot;&gt;
receiving errors in case of upstream message failures.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: inherit; color: #212121; font-family: Roboto, sans-serif; font-size: 16px; margin-bottom: 16px; margin-top: 16px; padding: 0px;&quot;&gt;
If you don&#39;t use these features, and you only care about displaying notifications messages when the app is not in the foreground, you can completely remove this service.&lt;/div&gt;
&lt;h3 id=&quot;update_the_android_manifest_1&quot; style=&quot;box-sizing: inherit; font-stretch: normal; line-height: 32px; margin: 32px 0px 16px; overflow: hidden; padding: 0px; text-overflow: ellipsis;&quot;&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;Update the Android Manifest&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;AndroidManifest.xml Before&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;service&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;.MyGcmListenerService&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:exported&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f;&quot;&gt;&quot;com.google.android.c2dm.intent.RECEIVE&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;AndroidManifest.xml After&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;service&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;.MyFcmListenerService&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;action&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;android:name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot; style=&quot;box-sizing: inherit; color: #0d904f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&quot;com.google.firebase.MESSAGING_EVENT&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;tag&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large; white-space: normal;&quot;&gt;Update your GcmListenerService&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Change MyGcmListenerService to extend FirebaseMessagingService and update the signature of the method&lt;span style=&quot;color: #cc0000;&quot;&gt; onMessageReceived().&lt;/span&gt; This example updates the service name to &lt;span style=&quot;color: #cc0000;&quot;&gt;MyFcmListenerService.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;MyGcmListenerService.java Before&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;MyGcmListenerService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;GcmListenerService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: inherit; color: #c53929;&quot;&gt;@Override&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; onMessageReceived&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7;&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0;&quot;&gt;Bundle&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; data&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;b&gt;MyFcmListenerService&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; white-space: normal;&quot;&gt;.&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000; font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; white-space: normal;&quot;&gt;java after&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit;&quot;&gt;
&lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;MyFcmListenerService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;FirebaseMessagingService&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: inherit; color: #c53929; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;@Override&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit;&quot;&gt;
   &lt;span style=&quot;color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; onMessageReceived&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;RemoteMessage&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; message&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;){&lt;/span&gt; 
&lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;      String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: inherit; color: #3b78e7; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt; message&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;getFrom&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;();&lt;/span&gt;
       &lt;span class=&quot;typ&quot; style=&quot;box-sizing: inherit; color: #9c27b0; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;Map&lt;/span&gt;&lt;string string=&quot;&quot; style=&quot;box-sizing: inherit; color: #37474f; font-family: &amp;quot;Roboto Mono&amp;quot;, monospace; font-size: 14px;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; data &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt; message&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: inherit;&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;();&lt;/span&gt;&lt;/string&gt;
&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace; font-size: 14px;&quot;&gt;  }&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;string string=&quot;&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/string&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;string string=&quot;&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/string&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; box-sizing: inherit; font-stretch: normal; line-height: 20px; overflow-x: auto; padding: 0px; position: relative;&quot;&gt;&lt;string string=&quot;&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: inherit;&quot;&gt;&lt;span style=&quot;color: #37474f; font-family: &amp;quot;roboto mono&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;Firebase has three message types:&lt;/b&gt;
&lt;/span&gt;&lt;span style=&quot;color: #37474f;&quot;&gt;
&lt;/span&gt;&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;Notification messages :&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot;; font-size: small; white-space: normal;&quot;&gt;Notification message works on background or foreground. When app is in background, Notification messages are delivered to the system tray. If the app is in the foreground, messages are handled by &lt;b&gt;onMessageReceived()&lt;/b&gt; or &lt;b&gt;didReceiveRemoteNotification&lt;/b&gt; callbacks. These are essentially what is referred to as Display messages.&lt;/span&gt;&lt;span style=&quot;color: #37474f;&quot;&gt;

&lt;/span&gt;&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;Data messages:&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot;; font-size: small; white-space: normal;&quot;&gt;On Android platform, data message can work on background and foreground. The data message will be handled by &lt;b&gt;onMessageReceived()&lt;/b&gt;. A platform specific note here would be: On Android, the data payload can be retrieved in the Intent used to launch your activity. To elaborate, if you have &quot;click_action&quot;:&quot;launch_Activity_1&quot;, you can retrieve this intent through getIntent() from only Activity_1.&lt;/span&gt;&lt;span style=&quot;color: #37474f;&quot;&gt;

&lt;/span&gt;&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;Messages with both notification and data payloads:&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot;; font-size: small; white-space: normal;&quot;&gt;When in the background, apps receive the notification payload in the notification tray, and only handle the data payload when the user taps on the notification. When in the foreground, your app receives a message object with both payloads available. Secondly, the click_action parameter is often used in notification payload and not in data payload. If used inside data payload, this parameter would be treated as custom key-value pair and therefore you would need to implement custom logic for it to work as intended.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/string&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/5162014124838150407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/09/migrate-gcm-client-app-for-android-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/5162014124838150407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/5162014124838150407'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/09/migrate-gcm-client-app-for-android-to.html' title='Migrate a GCM Client App for Android to Firebase Cloud Messaging'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-2608504841761466578</id><published>2016-03-10T00:31:00.001+05:30</published><updated>2016-09-16T00:11:44.596+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ArrayAdapter"/><category scheme="http://www.blogger.com/atom/ns#" term="BaseAdapter"/><category scheme="http://www.blogger.com/atom/ns#" term="comparison"/><category scheme="http://www.blogger.com/atom/ns#" term="CursorAdapter"/><category scheme="http://www.blogger.com/atom/ns#" term="GridLayoutManager"/><category scheme="http://www.blogger.com/atom/ns#" term="ItemAnimator"/><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayoutManager"/><category scheme="http://www.blogger.com/atom/ns#" term="List view"/><category scheme="http://www.blogger.com/atom/ns#" term="RecyclerView"/><category scheme="http://www.blogger.com/atom/ns#" term="SimpleCursorAdapter"/><category scheme="http://www.blogger.com/atom/ns#" term="StaggeredGridLayoutManager"/><category scheme="http://www.blogger.com/atom/ns#" term="ViewHolder"/><title type='text'>Comparison between android RecyclerView and ListView</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
Android is an evolving platform. Recently 5.0 (Lollipop) version of Android was released, along with the official RecyclerView support v7 library. As per the official documentation &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html&quot;&gt;RecyclerView&lt;/a&gt; is a major enhancement over &lt;a href=&quot;http://developer.android.com/guide/topics/ui/layout/listview.html&quot;&gt;ListView&lt;/a&gt;. It contains many new features like ViewHolder, ItemDecorator, LayoutManager, and SmoothScroller. But one thing that certainly gives it an edge over the ListView is; the ability to have animations while adding or removing an item. Here in Android RecyclerView vs ListView sum up I would compare the various features of RecyclerView and ListView and form an opinion why it should be used in new implementations.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Differences Between RecyclerView and ListView&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. View Holders&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
In ListView, defining view holders was a suggested approach for keeping references for views. But it was not a compulsion. Although by not doing so, ListView used show stale data. Another major drawback of not using view holders could lead to a heavy operation of finding views by ids every time. Which resulted in laggy ListViews.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
This problem is solved in RecylerView by the use of &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ViewHolder.html&quot;&gt;RecyclerView.ViewHolder&lt;/a&gt; class. This is one of the major differences in RecyclerView and ListView. When implementing a RecyclerView this class is used to define a ViewHolder object which is used by the adapter to bind ViewHolder with a position. Another point to be noted here, is that while implementing the adapter for RecyclerView, providing a ViewHolder is compulsory. This makes the implementation a little complex, but solves the issues faced in ListView.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;2. Layout Manager&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
When speaking of ListViews, only one type of ListView is available i.e. the vertical ListView. You cannot implement a ListView with horizontal scroll. I know there are ways to implement a horizontal scroll, but believe me it was not designed to work that way.&lt;br /&gt;
&lt;br /&gt;
But now when we look at Android RecyclerView vs ListView, we have support for horizontal collections as well. In-fact it supports multiple types of lists. To support multiple types of lists it uses RecyclerView.LayoutManager class. This is something new that ListView does not have. RecyclerView supports three types of predefined Layout Managers:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/LinearLayoutManager.html&quot;&gt;LinearLayoutManager&lt;/a&gt; – This is the most commonly used layout manager in case of RecyclerView. Through this, we can create both horizontal and vertical scroll lists.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/StaggeredGridLayoutManager.html&quot;&gt;StaggeredGridLayoutManager&lt;/a&gt; – Through this layout manager, we can create staggered lists. Just like the Pinterest screen.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html&quot;&gt;GridLayoutManager&lt;/a&gt;– This layout manager can be used to display grids, like any picture gallery.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;3. Item Animator&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Animations in a list is a whole new dimension, which has endless possibilities. In a ListView, as such there are no special provisions through which one can animate, addition or deletion of items. Instead later on as android evolved&amp;nbsp;&lt;a href=&quot;http://developer.android.com/reference/android/view/ViewPropertyAnimator.html&quot;&gt;ViewPropertyAnimator&lt;/a&gt; was suggested by Google’s Chet Haase in this &lt;a href=&quot;https://www.youtube.com/watch?v=8MIfSxgsHIs&quot;&gt;video tutorial&lt;/a&gt; for animations in ListView.&lt;br /&gt;
&lt;br /&gt;
On the other hand comparing Android RecyclerView vs ListView, it has &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemAnimator.html&quot;&gt;RecyclerView.ItemAnimator&lt;/a&gt; class for handling animations. Through this class custom animations can be defined for item addition, deletion and move events. Also it provides a&lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/DefaultItemAnimator.html&quot;&gt;DefaultItemAnimator&lt;/a&gt;, in case you don’t need any customizations.&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;4. Adapter&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
ListView adapters were simple to implement. They had a main method &lt;a href=&quot;http://developer.android.com/reference/android/widget/Adapter.html#getView%28int,%20android.view.View,%20android.view.ViewGroup%29&quot;&gt;getView&lt;/a&gt; where all the magic used to happen. Where the views were bound to a position. Also they used to have an interesting method &lt;a href=&quot;http://developer.android.com/reference/android/widget/Adapter.html#registerDataSetObserver%28android.database.DataSetObserver%29&quot;&gt;registerDataSetObserver&lt;/a&gt; where one can set an observer right in the adapter. This feature is also present in RecyclerView, but &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.AdapterDataObserver.html&quot;&gt;RecyclerView.AdapterDataObserver&lt;/a&gt; class is used for it. But the point in favor of ListView is that it supports three default implementations of adapters:&lt;br /&gt;
&lt;a href=&quot;http://developer.android.com/reference/android/widget/ArrayAdapter.html&quot;&gt;ArrayAdapter&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://developer.android.com/reference/android/widget/CursorAdapter.html&quot;&gt;CursorAdapter&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html&quot;&gt;SimpleCursorAdapter&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Whereas RecyclerView adapter, has all the functionality that ListView adapters had except the built in support for DB cursors and ArrayLists. In &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html&quot;&gt;RecyclerView.Adapter&lt;/a&gt; as of now we have to make a custom implementation to supply data to the adapter. Just like a &lt;a href=&quot;http://developer.android.com/reference/android/widget/BaseAdapter.html&quot;&gt;BaseAdapter&lt;/a&gt; does for ListViews.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;5. Item Decoration&lt;/b&gt;&lt;br /&gt;
To display custom dividers in a ListView, one could have easily added these parameters in the ListView XML:&lt;/div&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;br /&gt;android:divider=&quot;@android:color/transparent&quot;&lt;br /&gt;android:dividerHeight=&quot;5dp&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The interesting part about Android RecyclerView is that, as of now it does not show a divider between items by default. Although the guys at Google must have left this out for customization, intentionally. But this greatly increases the effort for a developer. If you wish to add a divider between items, you may need to do a custom implementation by using &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html&quot;&gt;RecyclerView.ItemDecoration&lt;/a&gt;class.&lt;br /&gt;
&lt;br /&gt;
Or you can apply a hack by using this file from official samples: &lt;a href=&quot;https://chromium.googlesource.com/android_tools/+/18728e9dd5dd66d4f5edf1b792e77e2b544a1cb0/sdk/extras/android/support/samples/Support7Demos/src/com/example/android/supportv7/widget/decorator/DividerItemDecoration.java&quot;&gt;DividerItemDecoration.java&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;6. OnItemTouchListener&lt;/b&gt;&lt;br /&gt;
Listviews used to have a simple implementation for detection of clicks, i.e. by the use of &lt;a href=&quot;http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html&quot;&gt;AdapterView.OnItemClickListener&lt;/a&gt;interface.&lt;br /&gt;
&lt;br /&gt;
But on the other hand &lt;a href=&quot;https://developer.android.com/reference/android/support/v7/widget/RecyclerView.OnItemTouchListener.html&quot;&gt;RecyclerView.OnItemTouchListener&lt;/a&gt; interface is used to detect touch events in Android RecyclerView. It complicates the implementation a little, but it gives a greater control to the developer for intercepting touch events. The official documentation states, it can be useful for gestural manipulations as it intercepts a touch event before it is delivered to RecyclerView.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/2608504841761466578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2016/03/comparison-between-android-recyclerview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/2608504841761466578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/2608504841761466578'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2016/03/comparison-between-android-recyclerview.html' title='Comparison between android RecyclerView and ListView'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-324038604692028923</id><published>2015-01-09T11:52:00.000+05:30</published><updated>2015-01-09T13:09:10.312+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AES"/><category scheme="http://www.blogger.com/atom/ns#" term="Base64"/><category scheme="http://www.blogger.com/atom/ns#" term="Cipher"/><category scheme="http://www.blogger.com/atom/ns#" term="KeySpec"/><category scheme="http://www.blogger.com/atom/ns#" term="MessageDigest"/><category scheme="http://www.blogger.com/atom/ns#" term="SecretKey"/><category scheme="http://www.blogger.com/atom/ns#" term="SecretKeyFactory"/><category scheme="http://www.blogger.com/atom/ns#" term="Sha1"/><title type='text'>Encrypt the password using algorithm and Decrypt it using one secret key</title><content type='html'>Its necessary to encrypt the user data that is not to be revealed by any third party user which can be harmful to the user.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There may be so many encryption and decryption techniques available for encrypt and decrypt the data. But I am posting one of them here.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Firstly, Copy following class into your code. And import all the classes.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;public class Encryption {&lt;br /&gt;&amp;nbsp; private static final String TAG = &quot;Encryption&quot;;&lt;br /&gt;&amp;nbsp; private String mCharsetName = &quot;UTF8&quot;;&lt;br /&gt;&amp;nbsp; private int mBase64Mode = Base64.DEFAULT;&lt;br /&gt;&amp;nbsp; private String mSecretKeyType = &quot;PBKDF2WithHmacSHA1&quot;;&lt;br /&gt;&amp;nbsp; private String mSalt = &quot;some_salt&quot;;&lt;br /&gt;&amp;nbsp; private int mKeyLength = 128;&lt;br /&gt;&amp;nbsp; private int mIterationCount = 65536;&lt;br /&gt;&amp;nbsp; private String mAlgorithm = &quot;AES&quot;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; public String encrypt(String key, String data) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (key == null || data == null)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SecretKey secretKey = getSecretKey(hashTheKey(key));&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte[] dataBytes = data.getBytes(mCharsetName);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cipher cipher = Cipher.getInstance(mAlgorithm);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cipher.init(Cipher.ENCRYPT_MODE, secretKey);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return Base64.encodeToString(cipher.doFinal(dataBytes), mBase64Mode);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (Exception e) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Log.e(TAG, e.toString());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp;public String decrypt(String key, String data) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (key == null || data == null)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byte[] dataBytes = Base64.decode(data, mBase64Mode);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SecretKey secretKey = getSecretKey(hashTheKey(key));&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cipher cipher = Cipher.getInstance(mAlgorithm);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cipher.init(Cipher.DECRYPT_MODE, secretKey);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byte[] dataBytesDecrypted = (cipher.doFinal(dataBytes));&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return new String(dataBytesDecrypted);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (Exception e) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Log.e(TAG, e.toString());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;private SecretKey getSecretKey(char[] key) throws NoSuchAlgorithmException,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UnsupportedEncodingException, InvalidKeySpecException {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SecretKeyFactory factory;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; factory = SecretKeyFactory.getInstance(mSecretKeyType);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KeySpec spec = new PBEKeySpec(key, mSalt.getBytes(mCharsetName),&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mIterationCount, mKeyLength);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SecretKey tmp = factory.generateSecret(spec);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return new SecretKeySpec(tmp.getEncoded(), mAlgorithm);&lt;br /&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;private char[] hashTheKey(String key) throws UnsupportedEncodingException,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NoSuchAlgorithmException {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MessageDigest md = MessageDigest.getInstance(&quot;SHA1&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;md.update(key.getBytes(mCharsetName));&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return Base64.encodeToString(md.digest(), Base64.NO_PADDING)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .toCharArray();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Using this class please create an object of it. Please set One secret key by which you want to encrypt the password.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;public static String secretKey = &quot;YourSecreteKey&quot;;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;Encryption encryption = new Encryption();&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
String encryptedPassword = encryption&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;
&lt;b&gt;.encrypt(&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;b style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;secretKey&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;
&lt;b&gt;, masterPassword&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;b&gt;&lt;/b&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;
&lt;b&gt;.getText().toString());&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;
using this secretKey you will get the encrypted data.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/324038604692028923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2015/01/encrypt-password-using-algorithm-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/324038604692028923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/324038604692028923'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2015/01/encrypt-password-using-algorithm-and.html' title='Encrypt the password using algorithm and Decrypt it using one secret key'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-1205157977565955742</id><published>2015-01-03T17:15:00.000+05:30</published><updated>2015-01-03T17:15:41.129+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="MessageDigest"/><category scheme="http://www.blogger.com/atom/ns#" term="Sha1"/><category scheme="http://www.blogger.com/atom/ns#" term="StringBuffer"/><title type='text'>Implement Message Digest algorithm</title><content type='html'>SHA1 message digest for securing your string for storing into database.&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Firstly create a method called sha1(String password). Here pass the password as a string as a parameter.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;String sha1(String input) throws NoSuchAlgorithmException {&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;MessageDigest mDigest = MessageDigest.getInstance(&quot;SHA1&quot;);&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;byte[] result = mDigest.digest(input.getBytes());&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;StringBuffer sb = new StringBuffer();&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (int i = 0; i &amp;lt; result.length; i++) {&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sb.append(Integer.toString((result[i] &amp;amp; 0xff) + 0x100, 16)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;.substring(1));&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return sb.toString();&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now just get the input from user and store it using this method into database&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;String shapassword = sha1(masterPassword.getText().toString().trim());&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/1205157977565955742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2015/01/implement-message-digest-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/1205157977565955742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/1205157977565955742'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2015/01/implement-message-digest-algorithm.html' title='Implement Message Digest algorithm'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-604599032961025755</id><published>2014-10-07T16:59:00.003+05:30</published><updated>2014-10-07T16:59:44.863+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Color"/><category scheme="http://www.blogger.com/atom/ns#" term="gradient"/><category scheme="http://www.blogger.com/atom/ns#" term="List view"/><title type='text'>Putting the divider in ListView</title><content type='html'>Here is the code for the divider in android list view.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;int[] colors = {0, 0xFFFF0000, 0};&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;myListview.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;myListview.setDividerHeight(1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This will brought into new gradient styled divider.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/604599032961025755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2014/10/putting-divider-in-listview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/604599032961025755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/604599032961025755'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2014/10/putting-divider-in-listview.html' title='Putting the divider in ListView'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-3805644873305568411</id><published>2013-11-23T03:08:00.000+05:30</published><updated>2013-11-23T03:08:08.058+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Uri"/><title type='text'>Get the Original file path From the Uri in the OnActivity Result</title><content type='html'>&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
First of all pass the Intent to pick the image from the external storage.. or gelllary&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
Intent intent = new Intent(Intent.ACTION_PICK,&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Images.Media.EXTERNAL_CONTENT_URI);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp; startActivityForResult(intent, 0);&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
OnActivityResult write the following code snippet&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
@Override&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp;protected void onActivityResult(int requestCode, int resultCode, Intent data) {&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; super.onActivityResult(requestCode, resultCode, data);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; if(resultCode == RESULT_OK){&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;image.setImageBitmap(null);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;//Uri return from external activity&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;orgUri = data.getData();&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;text1.setText(&quot;Returned Uri: &quot; + orgUri.toString() + &quot;\n&quot;);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;//path converted from Uri&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;convertedPath = getRealPathFromURI(orgUri);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;text2.setText(&quot;Real Path: &quot; + convertedPath + &quot;\n&quot;);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;//Uri convert back again from path&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;uriFromPath = Uri.fromFile(new File(convertedPath));&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; &amp;nbsp;text3.setText(&quot;Back Uri: &quot; + uriFromPath.toString() + &quot;\n&quot;);&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000; font-weight: bold;&quot;&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Getting the real path of the Image using the Uri returned in OnActivityResult...&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;public String getRealPathFromURI(Uri contentUri) {&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; String[] proj = { MediaStore.Images.Media.DATA };&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; //This method was deprecated in API level 11&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; //Cursor cursor = managedQuery(contentUri, proj, null, null, null);&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; CursorLoader cursorLoader = new CursorLoader(&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this,&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; contentUri, proj, null, null, null); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; Cursor cursor = cursorLoader.loadInBackground();&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; int column_index =&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; cursor.moveToFirst();&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; return cursor.getString(column_index);&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/3805644873305568411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/11/get-original-file-path-from-uri-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3805644873305568411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3805644873305568411'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/11/get-original-file-path-from-uri-in.html' title='Get the Original file path From the Uri in the OnActivity Result'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-3657185844903977222</id><published>2013-11-23T02:58:00.001+05:30</published><updated>2013-11-23T02:58:13.355+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="File"/><category scheme="http://www.blogger.com/atom/ns#" term="FilenameFilter"/><title type='text'>List of Files in the Directory with specified type </title><content type='html'>&lt;div&gt;
Pass the File Directory in the method and extension if you want to get the files with different file extensions.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;private File[] getJpgFiles(File f){&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; File[] files = f.listFiles(new FilenameFilter(){&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;@Override&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;public boolean accept(File dir, String filename) {&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; return filename.toLowerCase().endsWith(&quot;.jpg&quot;);&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;}});&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; return files;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/3657185844903977222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/11/list-of-files-in-directory-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3657185844903977222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3657185844903977222'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/11/list-of-files-in-directory-with.html' title='List of Files in the Directory with specified type '/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-1288399148256852953</id><published>2013-11-23T02:38:00.000+05:30</published><updated>2013-11-23T02:38:38.666+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="File"/><category scheme="http://www.blogger.com/atom/ns#" term="isDirectory"/><title type='text'>Delete Directory with its all the inner file and Directories</title><content type='html'>This is the simple method to remove all the files and folders from the path in the SDcard.&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;void DeleteRecursive(File fileOrDirectory) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (fileOrDirectory.isDirectory())&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for (File child : fileOrDirectory.listFiles())&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;DeleteRecursive(child);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;fileOrDirectory.delete();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/1288399148256852953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/11/delete-directory-with-its-all-inner.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/1288399148256852953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/1288399148256852953'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/11/delete-directory-with-its-all-inner.html' title='Delete Directory with its all the inner file and Directories'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-176490970455576162</id><published>2013-11-23T02:28:00.001+05:30</published><updated>2013-11-23T02:28:56.923+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Decompress"/><category scheme="http://www.blogger.com/atom/ns#" term="File"/><category scheme="http://www.blogger.com/atom/ns#" term="FileInputStream"/><category scheme="http://www.blogger.com/atom/ns#" term="FileOutputStream"/><category scheme="http://www.blogger.com/atom/ns#" term="ZipEntry"/><category scheme="http://www.blogger.com/atom/ns#" term="ZipInputStream"/><title type='text'>Unzipping the zip file with the location using ZipInputStream and ZIpEntry</title><content type='html'>Make a File with the name&amp;nbsp;&lt;b&gt;Decompress.java &lt;/b&gt;and add the following code snippet in it.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;import java.io.File;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;import java.io.FileInputStream;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;import java.io.FileOutputStream;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;import java.util.zip.ZipEntry;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;import java.util.zip.ZipInputStream;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;import android.util.Log;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;/**&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;*&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;* @author jon&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;*/&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;public class Decompress {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String _zipFile;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String _location;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Decompress(String zipFile, String location) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;_zipFile = zipFile;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;_location = location;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;_dirChecker(&quot;&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void unzip() {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;FileInputStream fin = new FileInputStream(_zipFile);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ZipInputStream zin = new ZipInputStream(fin);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ZipEntry ze = null;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;while ((ze = zin.getNextEntry()) != null) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Log.v(&quot;Decompress&quot;, &quot;Unzipping &quot; + ze.getName());&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if (ze.isDirectory()) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;_dirChecker(ze.getName());&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;} else {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;FileOutputStream fout = new FileOutputStream(_location&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;+ ze.getName());&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;for (int c = zin.read(); c != -1; c = zin.read()) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;fout.write(c);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;zin.closeEntry();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;fout.close();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;zin.close();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;deleteDir(_zipFile);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception e) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Log.e(&quot;Decompress&quot;, &quot;unzip&quot;, e);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void _dirChecker(String dir) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;File f = new File(_location + dir);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (!f.isDirectory()) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;f.mkdirs();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void deleteDir(String dir) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// TODO Auto-generated method stub&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;File f = new File(dir);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// Util.iLog(&quot;delete dir :&quot; + dir);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (f.exists()) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;f.delete();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
Now call these class with the zip file location and unzip location with the following code snippet&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;Decompress d = new Decompress(zipfileloc, Unziploc);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;d.unzip();&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/176490970455576162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/11/unzipping-zip-file-with-location-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/176490970455576162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/176490970455576162'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/11/unzipping-zip-file-with-location-using.html' title='Unzipping the zip file with the location using ZipInputStream and ZIpEntry'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-2128397919934868626</id><published>2013-11-23T02:07:00.000+05:30</published><updated>2013-11-23T02:07:57.035+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AsyncTask"/><category scheme="http://www.blogger.com/atom/ns#" term="Dialog"/><category scheme="http://www.blogger.com/atom/ns#" term="File"/><category scheme="http://www.blogger.com/atom/ns#" term="InputStream"/><category scheme="http://www.blogger.com/atom/ns#" term="onProgressUpdate"/><category scheme="http://www.blogger.com/atom/ns#" term="OutputStream"/><category scheme="http://www.blogger.com/atom/ns#" term="ProgressDialog"/><category scheme="http://www.blogger.com/atom/ns#" term="URLConnection"/><title type='text'>Download the large file from the server</title><content type='html'>Download the large file from the server asynchronously in android with the below code....&lt;br /&gt;
&lt;br /&gt;
call this:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;new DownloadFileAsync(YourActivity.this).execute();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
And your DownloadFileAsync is as below:&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;class DownloadFileAsync extends AsyncTask&amp;lt;String, String, String&amp;gt; {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;protected void onPreExecute() {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;super.onPreExecute();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;showDialog(DIALOG_DOWNLOAD_PROGRESS);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;protected String doInBackground(String... aurl) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;int count;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;try {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// URL url = new URL(DOWNLOAD URL);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;URLConnection conexion = url.openConnection();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;conexion.connect();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;int lenghtOfFile = conexion.getContentLength();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Log.d(&quot;ANDRO_ASYNC&quot;, &quot;Lenght of file: &quot; + lenghtOfFile);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;InputStream input = new BufferedInputStream(url.openStream());&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;File filedir = new File(path);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// have the object build the directory structure, if needed.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;filedir.mkdirs();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;OutputStream output = new FileOutputStream(path + name + &quot;.zip&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;byte data[] = new byte[1024];&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;long total = 0;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;while ((count = input.read(data)) != -1) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;total += count;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;publishProgress(&quot;&quot; + (int) ((total * 100) / lenghtOfFile),&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;name);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;output.write(data, 0, count);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;output.flush();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;output.close();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;input.close();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;} catch (Exception e) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return null;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;protected void onProgressUpdate(String... progress) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Log.d(&quot;ANDRO_ASYNC&quot;, progress[0]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog.setMessage(&quot;Downloading &quot; + progress[1] + &quot;.....&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog.setProgress(Integer.parseInt(progress[0]));&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;protected void onPostExecute(String unused) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;dismissDialog(DIALOG_DOWNLOAD_PROGRESS);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;new UnzipFile(BookDownloadActivity.this, path + name + &quot;.zip&quot;, path)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;.execute();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Override&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;protected Dialog onCreateDialog(int id) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;switch (id) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;case DIALOG_DOWNLOAD_PROGRESS:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog = new ProgressDialog(this);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog.setMessage(&quot;Downloading file.....&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog.setCancelable(false);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mProgressDialog.show();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return mProgressDialog;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;default:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return null;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
This is how you can download the whole file from the server or any other URLs.</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/2128397919934868626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/11/download-large-file-from-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/2128397919934868626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/2128397919934868626'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/11/download-large-file-from-server.html' title='Download the large file from the server'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-4893673975657836244</id><published>2013-08-29T09:43:00.003+05:30</published><updated>2013-08-29T09:44:27.306+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AsyncTask"/><category scheme="http://www.blogger.com/atom/ns#" term="THREAD_POOL_EXECUTOR"/><title type='text'>Run the same AsyncTask after completing itself.</title><content type='html'>Create an object of the task and execute the same task as following.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;UpdateCoin updatecoin = new UpdateCoin();&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (updatecoin.getStatus() == AsyncTask.Status.PENDING) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (updatecoin.getStatus() == AsyncTask.Status.RUNNING) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (updatecoin.getStatus() == AsyncTask.Status.FINISHED) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Runnable myRunner = new Runnable() {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void run() {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.HONEYCOMB) {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new UpdateCoin().executeOnExecutor(&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AsyncTask.THREAD_POOL_EXECUTOR, coin,&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LevelUpBonus[level - 1]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new UpdateCoin().executeOnExecutor(&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AsyncTask.THREAD_POOL_EXECUTOR, coin,&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LevelUpBonus[level - 1]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; myHandler.post(myRunner);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/4893673975657836244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/08/run-same-asynctask-after-completing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/4893673975657836244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/4893673975657836244'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/08/run-same-asynctask-after-completing.html' title='Run the same AsyncTask after completing itself.'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-517793442403364543</id><published>2013-07-16T11:40:00.000+05:30</published><updated>2013-07-16T11:41:43.239+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AsyncTask"/><category scheme="http://www.blogger.com/atom/ns#" term="THREAD_POOL_EXECUTOR"/><title type='text'>Ecxecute two Different AsyncTask parallel in android </title><content type='html'>If you want to ecxecute the two different asynctask to be ecxecute parallelly then you shoul use the second async task ecxecution like below. &amp;nbsp;&lt;b style=&quot;color: #cc0000;&quot;&gt;UpdateCoin &lt;/b&gt;is the Async task.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp;if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.HONEYCOMB) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                &lt;/span&gt;new UpdateCoin().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                                                                                    &lt;/span&gt;mPref.getInt(&quot;UserCoin&quot;, 0), CalculatedCoin);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} else {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                &lt;/span&gt;new UpdateCoin().execute(mPref.getInt(&quot;UserCoin&quot;, 0),&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000;&quot;&gt;CalculatedCoin);&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/517793442403364543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/07/ecxecute-two-different-asynctask.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/517793442403364543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/517793442403364543'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/07/ecxecute-two-different-asynctask.html' title='Ecxecute two Different AsyncTask parallel in android '/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-5198725975281784826</id><published>2013-06-04T11:15:00.000+05:30</published><updated>2013-06-04T11:15:05.841+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Collections"/><category scheme="http://www.blogger.com/atom/ns#" term="Comparator"/><title type='text'>Sorting the ArrayList by Name and Value in android</title><content type='html'>Sorting the ArrayList by String comparison by the Following code.&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;Collections.sort(name, new Comparator&amp;lt;YOURARRAYLISTNAME&amp;gt;() {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; @Override&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; public int compare(Invitation lhs, Invitation rhs) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;return lhs.getName().compareToIgnoreCase(rhs.getName());&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;});&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
You&amp;nbsp;can also compare Arraylist by INTEGER value by following code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;Collections.sort(value, new Comparator&amp;lt;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000;&quot;&gt;YOURARRAYLISTNAME&lt;/b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;gt;() {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; @Override&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; public int compare(Invitation lhs, Invitation rhs) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return (&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000;&quot;&gt;lhs&lt;/b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;.expenditure &amp;lt; r&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000;&quot;&gt;hs&lt;/b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;.expenditure ? 1 : -1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;});&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/5198725975281784826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/06/sorting-arraylist-by-name-and-value-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/5198725975281784826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/5198725975281784826'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/06/sorting-arraylist-by-name-and-value-in.html' title='Sorting the ArrayList by Name and Value in android'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-9024405323048154957</id><published>2013-05-23T21:48:00.000+05:30</published><updated>2013-05-23T21:48:35.418+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ChaeSequence"/><category scheme="http://www.blogger.com/atom/ns#" term="Matcher"/><category scheme="http://www.blogger.com/atom/ns#" term="Pattern"/><title type='text'>Validate the String for the Email</title><content type='html'>&lt;br /&gt;
Here is the method for checking the String is email address or not.&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;private boolean checkemail(String emailstr) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// TODO Auto-generated method stub&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean isValid = false;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;String expression = &quot;^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$&quot;;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;CharSequence inputStr = emailstr;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;Matcher matcher = pattern.matcher(inputStr);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;if (matcher.matches()) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;isValid = true;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;return isValid;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;  &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
For validate the String use following:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;if(checkemail(emailstr)){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; // Here do with the Email string&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}else{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; System.out.println(&quot;email String is not valid&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/9024405323048154957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/05/validate-string-for-email.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/9024405323048154957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/9024405323048154957'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/05/validate-string-for-email.html' title='Validate the String for the Email'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-28985422513162108</id><published>2013-05-09T18:49:00.001+05:30</published><updated>2013-05-10T17:53:59.177+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharedPreferences"/><title type='text'>Get the number of times app is used</title><content type='html'>&lt;br /&gt;

&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;&amp;nbsp;private SharedPreferences mPref;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static final String PREFS_NAME = &quot;YourPrefName&quot;;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int c;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;in onCreate() write the following&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; mPref = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;c = mPref.getInt(&quot;numRun&quot;, 0);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Log.i(&quot;TAG&quot;, &quot;Number of count of open App:&quot; + c);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;c++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;mPref.edit().putInt(&quot;numRun&quot;, c).commit();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Log.i(&quot;TAG&quot;, &quot;Number of count after commit of open App:&quot; + c);&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/28985422513162108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/05/get-number-of-times-app-ids-used.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/28985422513162108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/28985422513162108'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/05/get-number-of-times-app-ids-used.html' title='Get the number of times app is used'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-6309653604508432551</id><published>2013-04-13T11:31:00.001+05:30</published><updated>2013-04-13T11:31:06.080+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="CountDownTimer"/><title type='text'>Count Down Timer in android</title><content type='html'>&lt;b&gt;Android provide a android.os.CountDownTimer. By new a CountDownTimer object, and overriding the call-back function onTick() and onFinish(), you can implement a count down timer easily.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;public class CountDownTimerActivity extends Activity {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; public void onCreate(Bundle savedInstanceState) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;super.onCreate(savedInstanceState);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;setContentView(R.layout.main);&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final TextView myCounter = (TextView)findViewById(R.id.mycounter);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CountDownTimer(30000, 1000) {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void onFinish() {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// TODO Auto-generated method stub&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;myCounter.setText(&quot;completed Timer!&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void onTick(long millisUntilFinished) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // TODO Auto-generated method stub&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;myCounter.setText(&quot;Millisecond Until Finished: &quot; + String.valueOf(millisUntilFinished));&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}.start();&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Xml file will be below.&lt;/b&gt;&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:layout_width=&quot;fill_parent&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:layout_height=&quot;fill_parent&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:orientation=&quot;vertical&quot; &amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; &amp;lt;TextView&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:layout_width=&quot;fill_parent&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:layout_height=&quot;wrap_content&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:text=&quot;@string/hello&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; &amp;lt;TextView&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:id=&quot;@+id/mycounter&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:layout_width=&quot;fill_parent&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; android:layout_height=&quot;wrap_content&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/6309653604508432551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/04/count-down-timer-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/6309653604508432551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/6309653604508432551'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/04/count-down-timer-in-android.html' title='Count Down Timer in android'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-6625682823511635651</id><published>2013-03-31T16:20:00.000+05:30</published><updated>2013-03-31T16:26:23.564+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Alert Dialog"/><category scheme="http://www.blogger.com/atom/ns#" term="Bundle"/><category scheme="http://www.blogger.com/atom/ns#" term="Dialog"/><category scheme="http://www.blogger.com/atom/ns#" term="DialogFragment"/><category scheme="http://www.blogger.com/atom/ns#" term="Toast"/><title type='text'>DialogFragment</title><content type='html'>android.app.DialogFragment, was introduced from API Level 11 (Android 3.0), displays a dialog window, floating on top of its activity&#39;s window.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggi4dIdJu6BwWm9HrlESk5kiqaH5U4bjCCB5uT7oYrgIUVKrfx7goO9T-jfDMNVh2uL2taPNa9uR2U4bp1V9Ed_iI1kabJlHdgKXSWMgakMu9OXEg1pKMMYJZ7krbdJAKBP7F1_thiB7M/s1600/DialogFragment.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggi4dIdJu6BwWm9HrlESk5kiqaH5U4bjCCB5uT7oYrgIUVKrfx7goO9T-jfDMNVh2uL2taPNa9uR2U4bp1V9Ed_iI1kabJlHdgKXSWMgakMu9OXEg1pKMMYJZ7krbdJAKBP7F1_thiB7M/s320/DialogFragment.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;public class MyDialogFragment extends DialogFragment {&lt;br /&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static MyDialogFragment newInstance() {&lt;br /&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String title = &quot;My Fragment&quot;;&lt;br /&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyDialogFragment f = new MyDialogFragment();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bundle args = new Bundle();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; args.putString(&quot;title&quot;, title);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f.setArguments(args);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return f;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public Dialog onCreateDialog(Bundle savedInstanceState) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String title = getArguments().getString(&quot;title&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dialog myDialog = new AlertDialog.Builder(getActivity())&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.setIcon(R.drawable.ic_launcher)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.setTitle(title)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.setPositiveButton(&quot;OK&quot;,&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new DialogInterface.OnClickListener() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onClick(DialogInterface dialog, int which) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((AndroidDialogFragmentActivity)getActivity()).okClicked();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; })&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .setNegativeButton(&quot;Cancel&quot;, &lt;br /&gt; new DialogInterface.OnClickListener() {&lt;br /&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onClick(DialogInterface dialog, int which) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((AndroidDialogFragmentActivity)getActivity()).cancelClicked();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;})&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .create();&lt;br /&gt;&lt;br /&gt; return myDialog;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
in main.xml modify the following code.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt; android:layout_height=&quot;fill_parent&quot;&lt;br /&gt; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;TextView&lt;br /&gt; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt; android:text=&quot;@string/hello&quot; /&amp;gt;&lt;br /&gt; &amp;lt;Button&lt;br /&gt; android:id=&quot;@+id/opendialog&quot;&lt;br /&gt; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt; android:text=&quot;Open Dialog&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
now in your activity just change the following code and see the dialog&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;public class DialogFragmentActivity extends Activity {&lt;/b&gt;&lt;/div&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /** Called when the activity is first created. */&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onCreate(Bundle savedInstanceState) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; super.onCreate(savedInstanceState);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setContentView(R.layout.main);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Button buttonOpenDialog = (Button)findViewById(R.id.opendialog);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; buttonOpenDialog.setOnClickListener(new Button.OnClickListener(){&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void onClick(View arg0) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OpenDialog();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }});&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void OpenDialog(){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MyDialogFragment myDialogFragment = MyDialogFragment.newInstance();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;myDialogFragment.show(getFragmentManager(), &quot;myDialogFragment&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void okClicked() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Toast.makeText(AndroidDialogFragmentActivity.this,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;OK Clicked!&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Toast.LENGTH_LONG).show();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void cancelClicked() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Toast.makeText(AndroidDialogFragmentActivity.this,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Cancel Clicked!&quot;, &amp;nbsp;Toast.LENGTH_LONG).show();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/6625682823511635651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/03/dialogfragment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/6625682823511635651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/6625682823511635651'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/03/dialogfragment.html' title='DialogFragment'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggi4dIdJu6BwWm9HrlESk5kiqaH5U4bjCCB5uT7oYrgIUVKrfx7goO9T-jfDMNVh2uL2taPNa9uR2U4bp1V9Ed_iI1kabJlHdgKXSWMgakMu9OXEg1pKMMYJZ7krbdJAKBP7F1_thiB7M/s72-c/DialogFragment.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-3331097614441350441</id><published>2013-03-31T15:26:00.002+05:30</published><updated>2013-03-31T15:27:19.223+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Canvas"/><category scheme="http://www.blogger.com/atom/ns#" term="Color"/><category scheme="http://www.blogger.com/atom/ns#" term="context"/><category scheme="http://www.blogger.com/atom/ns#" term="DrawBarChart"/><category scheme="http://www.blogger.com/atom/ns#" term="Paint"/><title type='text'>Draw bar chart in android</title><content type='html'>This is the same as the &lt;a href=&quot;http://typicaljava.blogspot.in/2013/03/draw-piechart-in-android-using-view.html&quot;&gt;&lt;b&gt;Last Tutorial i have posted&lt;/b&gt;&lt;/a&gt;. We just need to implement the following code in the View instead of the last tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;public class DrawBarChart extends View {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Paint paint = new Paint();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int c[] = { Color.BLUE, Color.RED };&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Canvas mCanvas = new Canvas();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private float[] val_exp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private float[] val_inco;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Context context;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;WindowManager mWinMgr;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public DrawBarChart(Context context) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super(context);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint = new Paint();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super.draw(mCanvas);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public DrawBarChart(Context context, AttributeSet attrs) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super(context, attrs);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint = new Paint();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super.draw(mCanvas);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public DrawBarChart(Context context, float[] val_exp, float[] val_inco) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super(context);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint = new Paint();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.val_exp = val_exp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.val_inco = val_inco;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super.draw(mCanvas);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void draw(Canvas canvas) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int x = getWidth();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int y = getHeight();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;float max = getMax();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint.setColor(Color.parseColor(&quot;#78777D&quot;));&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint.setStyle(Style.STROKE);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint.setStrokeWidth(2);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;canvas.drawRect(0, 0, x - 1, y - 1, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int n = val_exp.length;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int gap = x / 12;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;paint.setStyle(Style.FILL);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for (int i = 0; i &amp;lt; n; i++) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;   &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;paint.setColor(Color.BLACK);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;//Bottom Numbers 1 to 12.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;canvas.drawText(&quot;&quot; + (i + 1), i * gap + (gap / 2), y - 5, paint); &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;//Vertical Lines.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;canvas.drawLine((float) (i + 0.5) * gap + 4, y - 15,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;(float) (i + 0.5) * gap + 4, y - 25, paint); &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Blue bars for Income.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;paint.setColor(Color.BLUE);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;canvas.drawLine(i * gap + 5, y - 20, (float) (i + 0.5) * gap + 3,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;y - 20, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;   &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;float bHeIn =(max==0)?y-20: &amp;nbsp;y - (val_inco[i] * (y - 22) / max)- 20;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;   &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;canvas.drawRect((float) i &amp;nbsp; * gap + 5, bHeIn,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;(float) (i + 0.5) * gap + 3, y - 20, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;   &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Red bars for Expenses.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;paint.setColor(Color.RED);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;canvas.drawLine((float) (i + 0.5) * gap + 5, y - 20,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;(float) (i + 1) * gap + 3, y - 20, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;float bHeEx =(max==0)?y-20: &amp;nbsp;y - (val_exp[i] * (y - 22) / max)- 20;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;   &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;canvas.drawRect((float) (i + 0.5) * gap + 5, bHeEx,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;(float) (i + 1) * gap + 3, y - 20, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private float getMax() {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;float max = 0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for (float f : val_exp) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (f &amp;gt; max)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;max = f;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for (float f : val_inco) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (f &amp;gt; max)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;max = f;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return max;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
And for drawing the chart of the values of the data you need to pass the values to the objects of the class as follow. &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;DrawBarChart barView;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LinearLayout la;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;barView = new DrawBarChart(this, vals_exp,vals_inco);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la.addView(barView);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/3331097614441350441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/03/draw-bar-chart-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3331097614441350441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/3331097614441350441'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/03/draw-bar-chart-in-android.html' title='Draw bar chart in android'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-1172527072172699409</id><published>2013-03-31T14:40:00.000+05:30</published><updated>2013-03-31T14:40:58.304+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Canvas"/><category scheme="http://www.blogger.com/atom/ns#" term="context"/><category scheme="http://www.blogger.com/atom/ns#" term="DrawPieChart"/><category scheme="http://www.blogger.com/atom/ns#" term="Paint"/><category scheme="http://www.blogger.com/atom/ns#" term="Piechart"/><category scheme="http://www.blogger.com/atom/ns#" term="RelativeLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="View"/><title type='text'>Draw PieChart in android using View</title><content type='html'>Fitst of all make an Relative layout as the below in your XML file to Display Pie chart on that view.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;lt;RelativeLayout&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:id=&quot;@+id/piechart_lay&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:layout_width=&quot;150dip&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:layout_height=&quot;150dip&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:layout_margin=&quot;5dip&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:background=&quot;#eeffee&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:orientation=&quot;horizontal&quot; &amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
Now we have to make a View which make the actual pie chart and draw and fill the color in the chart. Create one file let&#39;s say DrawPieChart.java extends View and add the following code snippet in it.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;public class DrawPieChart extends View {&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Paint paint = new Paint();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;// &amp;nbsp;Here you can Add number of different color according to max different colors to be displayed on Piechart&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int c[] = {Color.MAGENTA,Color.BLUE,Color.RED,Color.CYAN,Color.YELLOW,Color.GREEN};&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Canvas mCanvas = new Canvas();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;private int[] values;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Context context;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;public DrawPieChart(Context context, int[] values) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;super(context);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;paint = new Paint();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;this.values = values;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;// this.labels = labels;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;super.draw(mCanvas);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;public void draw(Canvas canvas) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;int x = getWidth();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;int y = getHeight();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;float t = getTotal();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;paint.setColor(Color.parseColor(&quot;#78777D&quot;));&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;paint.setStyle(Style.STROKE);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;paint.setStrokeWidth(2);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;canvas.drawRect(0, 0, x - 1, y - 1, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;int n = values.length;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;float cuurPos = -90;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;paint.setStyle(Style.FILL);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;RectF rect = new RectF(20,20,x-20,y-20);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; n; i++) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;paint.setColor(c[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;float thita =(t==0)?0: 360*values[i]/t;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;canvas.drawArc(rect, cuurPos, thita, true, paint);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;cuurPos = cuurPos+thita;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;private float getTotal() {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;int total = 0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; values.length; i++) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;total = total + values[i];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;return total;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
Now create an object of this class in your activity and pass the Array of the values to the object and it will create the Piechart in the Relative layout. You have to add this view in the Activity to your relative layout.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;class Piechart extends Activity{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RelativeLayout la;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;DrawPieChart piView;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;int[] vals;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;public void onCreate(Bundle savedInstanceState) {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;super.onCreate(savedInstanceState);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;setContentView(R.layout.relative);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la = (RelativeLayout) findViewById(R.id.pie_lay);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; getPieChart();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void &amp;nbsp;getPieChart(){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;vals[] = new vals[YOUR SIZE OF ARRAY];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;vals = {12,14,23,35,23,56,78};&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;piView = new DrawPieChart(Analisys.this, vals);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;la.removeAllViews();&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;la.addView(piView);&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/1172527072172699409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/03/draw-piechart-in-android-using-view.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/1172527072172699409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/1172527072172699409'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/03/draw-piechart-in-android-using-view.html' title='Draw PieChart in android using View'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7471395497203692205.post-991756831865092265</id><published>2013-03-30T10:34:00.000+05:30</published><updated>2013-03-30T10:38:56.169+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Handler"/><category scheme="http://www.blogger.com/atom/ns#" term="Imagebutton"/><category scheme="http://www.blogger.com/atom/ns#" term="MediaPlayer"/><category scheme="http://www.blogger.com/atom/ns#" term="Runnable"/><category scheme="http://www.blogger.com/atom/ns#" term="Seekbar"/><title type='text'>Streaming songs from Url in Default Media Player</title><content type='html'>&lt;div&gt;
Here i am posting with the example code of the streaming the songs from the Url in android with android default media player.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
First of all you just have to make the XML file with the following lines&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;lt;RelativeLayout&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;android:layout_height=&quot;fill_parent&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;android:focusable=&quot;true&quot;&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;EditText&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:text=&quot;The song URL&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:id=&quot;@+id/EditTextSongURL&quot;/&amp;gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;ImageButton&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_below=&quot;@+id/EditTextSongURL&quot;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:id=&quot;@+id/ButtonTestPlayPause&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_width=&quot;match_parent&quot;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:src=&quot;@drawable/button_play&quot;/&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;SeekBar&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_below=&quot;@+id/ButtonTestPlayPause&quot;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:id=&quot;@+id/SeekBarTestPlay&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:layout_width=&quot;match_parent&quot;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;android:thumb=&quot;@drawable/thumb_transparent&quot;/&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now in you main Activity class replace with the following code and enter the URL of your server song and hit play.&lt;/div&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;public class StreamingPlayer extends Activity implements OnClickListener, OnTouchListener, OnCompletionListener, OnBufferingUpdateListener{&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;private ImageButton buttonPlayPause;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;private SeekBar seekBarProgress;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;public EditText editTextSongURL;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;private MediaPlayer mediaPlayer;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;// this value contains the song duration in milliseconds. Loook at getDuration() method in MediaPlayer class&lt;/b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000;&quot;&gt;private int mediaFileLengthInMilliseconds;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;private final Handler handler = new Handler();&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;** Called when the activity is first created. */&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;@Override&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;public void onCreate(Bundle savedInstanceState) {&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;super.onCreate(savedInstanceState);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;setContentView(R.layout.main);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;initView();&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;/** This method initialise all the views in project*/&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;private void initView() {&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;buttonPlayPause = (ImageButton)findViewById(R.id.ButtonTestPlayPause);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;buttonPlayPause.setOnClickListener(this);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;seekBarProgress = (SeekBar)findViewById(R.id.SeekBarTestPlay); &lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;seekBarProgress.setMax(99); // It means 100% .0-99&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;seekBarProgress.setOnTouchListener(this);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;editTextSongURL = (EditText)findViewById(R.id.EditTextSongURL);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;editTextSongURL.setText(R.string.testsong_20_sec);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mediaPlayer = new MediaPlayer();&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mediaPlayer.setOnBufferingUpdateListener(this);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mediaPlayer.setOnCompletionListener(this);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;/** Method which updates the SeekBar primary progress by current song playing position*/&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;private void primarySeekBarProgressUpdater() {&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; seekBarProgress.setProgress((int) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (((float)mediaPlayer.getCurrentPosition()/mediaFileLengthInMilliseconds)*100)); // This math construction give a percentage of &quot;was playing&quot;/&quot;song length&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (mediaPlayer.isPlaying()) {&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Runnable notification = new Runnable() {&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void run() {&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; primarySeekBarProgressUpdater();&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;};&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; handler.postDelayed(notification,1000);&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;@Override&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #cc0000;&quot;&gt;public void onClick(View v) {&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(v.getId() == R.id.ButtonTestPlayPause){&lt;br /&gt;/** ImageButton onClick event handler. Method which start/pause mediaplayer playing */&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #cc0000;&quot;&gt;&amp;nbsp;// setup song&amp;nbsp;URL to mediaplayer data source&lt;/b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mediaPlayer.setDataSource(editTextSongURL.getText().toString());&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;mediaPlayer.prepare();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} catch (Exception e) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;mediaFileLengthInMilliseconds = mediaPlayer.getDuration();&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(!mediaPlayer.isPlaying()){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mediaPlayer.start();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; buttonPlayPause.setImageResource(R.drawable.button_pause);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mediaPlayer.pause();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; buttonPlayPause.setImageResource(R.drawable.button_play);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; primarySeekBarProgressUpdater();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public boolean onTouch(View v, MotionEvent event) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(v.getId() == R.id.SeekBarTestPlay){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/** Seekbar onTouch event handler. Method which seeks MediaPlayer to seekBar &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;primary progress position*/&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(mediaPlayer.isPlaying()){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SeekBar sb = (SeekBar)v;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int playPositionInMillisecconds = (mediaFileLengthInMilliseconds / 100) * sb.getProgress();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mediaPlayer.seekTo(playPositionInMillisecconds);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;@Override&lt;br /&gt;public void onCompletion(MediaPlayer mp) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/** MediaPlayer onCompletion event handler. Method which calls then song playing is complete*/&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;buttonPlayPause.setImageResource(R.drawable.button_play);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public void onBufferingUpdate(MediaPlayer mp, int percent) {&lt;br /&gt;/** Method which updates the SeekBar secondary progress by current song loading from URL position*/&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;seekBarProgress.setSecondaryProgress(percent);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://typicaljava.blogspot.com/feeds/991756831865092265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://typicaljava.blogspot.com/2013/03/streaming-media-player-with-song-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/991756831865092265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7471395497203692205/posts/default/991756831865092265'/><link rel='alternate' type='text/html' href='http://typicaljava.blogspot.com/2013/03/streaming-media-player-with-song-url.html' title='Streaming songs from Url in Default Media Player'/><author><name>Arpit Patel</name><uri>http://www.blogger.com/profile/13181030929445266594</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>