How to fix the orientation from androidmanifest?

Just you have to define below property to your activity inside manifest file, It will restrict your activity to portrait.

android:screenOrientation=”portrait”

Example:

        <activity
            android:name="com.example.demo_spinner.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>

If you want to do using java code try

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

before you setContentView for your activity in onCreate(). Hope this help and easy to understand for everyone!

Display HTML format text in WebView

I have faced this problem to show the HTML format text show in WebView
I found the solution for this and lets share it –

Create a xml with WebView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</LinearLayout>

Continue Reading

Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio

Today I was facing this issue “Cannot resolve symbol DefaultHttpClient” while parsing JSON in my application.

So Friends!! if you are also facing or will face the same issue then I’m giving you the solution for it. HttpClient was deprecated in API Level 22 and removed in API Level 23, You have to use URL Conntection. If you need SDK 23, add this to your gradle:
Continue Reading