Create a AlertDialog with LayoutInflater in Android


Originally posted on Programming Blog:
Create a beautiful AlertDialog box in android by inflating a XML layout. ? For example: dialog_example.xml Keep it layout folder <?xml version=”1.0″ encoding=”utf-8″?> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android&#8221; android:id=”@+id/rl_custom_layout” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_centerInParent=”true” android:layout_marginLeft=”45dp” android:layout_marginRight=”45dp” android:background=”@color/accent_white”> <RelativeLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@drawable/border_popup”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@color/accent_white” android:orientation=”vertical”> <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:textAlignment=”center” android:layout_marginTop=”25dp” android:text=”Are you sure” android:textColor=”@color/text_color_sign_up”…

Select Image from Camera or Gallery in Android


Originally posted on Programming Blog:
Select Image from Camera or Gallery in Android // Add the codes in the manifest file above the application <uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE” /> <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” /> // Add The following variables the java class private static final int REQUEST_CAMERA = 1; private static final int SELECT_FILE = 2; String userChoosenTask; Bitmap…

Add a video stream in Android App!


Originally posted on Android With Divya Jain:
Here I demonstrate how to add a video stream to your android application. VideoView class is a visual component which provides a surface onto which the video is played. Add a VideoView to the main layout xml file <VideoView android:id=”@+id/myVideo” android:layout_width=”500dp” android:layout_height=”300dp” android:layout_centerInParent=”true”/> Retrieve a reference to the…

Resolving Dependency Conflict In Android Studio


Originally posted on Android With Divya Jain:
Recently I created a new project in Android Studio. And without adding any code, I got the following build error : Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. > Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.…

Tab layout with Fragment


To start off please include these libraries in the dependencies section of your build.gradle file: build.gradle (app) 1 2 compile ‘com.android.support:appcompat-v7:22.2.0’ compile ‘com.android.support:design:22.2.0’ Next, to display Android tabs with fragment and ViewPager, lets define three simple fragments and their layouts: TabFragment1.java Java 1 2 3 4 5 6 7 8 9 10 11 12 13 … More Tab layout with Fragment

Weather app android code


create a Weather API from OpenWeatherMap. //ws-in.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=IN&source=ac&ref=tf_til&ad_type=product_link&tracking_id=mukes-21&marketplace=amazon&region=IN&placement=B01DB93B6G&asins=B01DB93B6G&linkId=2a3051c4ef156d7fd1e530126635df9c&show_border=true&link_opens_in_new_window=true&price_color=333333&title_color=0066c0&bg_color=ffffff//ws-in.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=IN&source=ac&ref=tf_til&ad_type=product_link&tracking_id=mukes-21&marketplace=amazon&region=IN&placement=B06XQKMDTJ&asins=B06XQKMDTJ&linkId=2bbef01e5603af1a3e2d66cf8f293a74&show_border=true&link_opens_in_new_window=true&price_color=333333&title_color=0066c0&bg_color=ffffff//ws-in.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=IN&source=ac&ref=tf_til&ad_type=product_link&tracking_id=mukes-21&marketplace=amazon&region=IN&placement=B00130WAQS&asins=B00130WAQS&linkId=2768a93fdb329a8fa6e61d294b116b69&show_border=true&link_opens_in_new_window=true&price_color=333333&title_color=0066c0&bg_color=ffffff//ws-in.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=IN&source=ac&ref=tf_til&ad_type=product_link&tracking_id=mukes-21&marketplace=amazon&region=IN&placement=B01N2XLSMW&asins=B01N2XLSMW&linkId=41ad0022b3ba5089762754c04c310049&show_border=true&link_opens_in_new_window=true&price_color=333333&title_color=0066c0&bg_color=ffffff//ws-in.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=IN&source=ac&ref=tf_til&ad_type=product_link&tracking_id=mukes-21&marketplace=amazon&region=IN&placement=B0036E2VB8&asins=B0036E2VB8&linkId=60cae8465a135031f8e1a3e26187749b&show_border=true&link_opens_in_new_window=true&price_color=333333&title_color=0066c0&bg_color=ffffff Copy weathericons-regular-webfont.ttf to your project’s src/main/assets/fonts directory. download the font from here. Open  AndroidManifest.xml file and add internet connect permission. Your manifest file will look like this- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 … More Weather app android code

Android code for rate us and more apps


First we look at Rate Us : Code Snippet: final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(your link here))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(your link here))); } Here the app actually search for the certain package name in the market. So, if your … More Android code for rate us and more apps