Monday, April 1, 2013

How to add Webview as a ListView item in android

Hello friends, :)

This is very easy process.
But when we add webviews as a row item in ListView that time Webview showing wrong url, Its a issue with custom ListView but for that we use holder to hold view.

But problem as it is with listview bcz at the time of loading webpag webview height increases as per webpages.

So for that issue. I write very efficient code. 
Its output look like WebView showing as listview row item.
I will explain as follows. Please check it.

Step 1.  main_relLay.xml
For adding scroll view and linear layout

<RelativeLayout 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" >

    <ScrollView
        android:id="@+id/scrollview"
        android:layout_width="fill_parent"
        android:layout_height="450dp" >

        <LinearLayout
            android:id="@+id/main_relLay"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#0B7A3B"
            android:orientation="vertical" >
        </LinearLayout>
    </ScrollView>

</RelativeLayout>

Description: ScrollView use for listview effect. Linear Layout have a dynamic content (WebView) of rows.

Step 2: row.xml
For ListView row item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/row_relLay"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#F70925" >

        <ProgressBar
            android:id="@+id/progressbar"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="visible" />

        <WebView
            android:id="@+id/row_webView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:visibility="gone" >
        </WebView>
    </RelativeLayout>

</LinearLayout>

Description: Create another xml for listview row items.

Java file :
Using LayoutInflater load view of row.xml for listview row.
And add this row.xml in main.xml linear layout its avaialable in scroll view, This is main linear layout provide listview effect.

Step A: LinearLayout relLay = (LinearLayout) findViewById(R.id.main_relLay);
Step B: LayoutInflater inflater = (LayoutInflater) getApplication()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Step C: View v_child = inflater.inflate(R.layout.row, null);
Step D:  relLay.addView(v_child);



For more information or help regarding that,
Contact:
Mail ID : ranjitvcsc@gmail.com

Wednesday, February 27, 2013

Push Notification (GCM,C2DM) in Android

"Push Notification" this is from iPhone,
In Android this is GCM(Google Cloud Messaging), C2DM.

Check this is best links for Android

***Source code for ANDROID also for OWN SERVER***
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

***GCM Architecture Overview***
http://developer.android.com/google/gcm/gcm.html
http://developer.android.com/google/gcm/gs.html

** Registering Process with GCM ***
http://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/

***C2DM***
http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html

NOTE:
Google has officially deprecated C2DM as of June 26,2012. This means that
C2DM has stopped accepting new users and quota requests. Existing C2DM
developers are encouraged to migrate to Google's new push service, called
GoogleCloud messaging for Android (GCM).
               ->From : https://docs.urbanairship.com/pages/viewpage.action?pageId=1509252

Friday, February 22, 2013

In Android how to storing and retrieving images as a BLOB from SQLite Database

This is 2 import link for storing and retrieving images as a BLOB from SQLite Database.

http://android-codes-examples.blogspot.in/2011/09/image-and-content-is-populated-from.html


http://sree.cc/google/storing-and-retriving-images-in-sqlite-database-in-android


> First link showing full process and also showing retrived data in listview.
> Second link have a code to convert online image as a BLOB and storing in SQLite DB. Also having the process of retrieving same image and convert in an bitmap format.

Friday, February 15, 2013

How to finish all Activity's running in background in Android

---------------------------------------------------------------------------
Hello All,

This is very easy solution for this question.

A->B->C->D

We start from A and now we are on D activity.

We used intent for jump one activity to another.

Note: yet we not use finish...

Means A,B,C is running in background...

So, therefore we need to finish all (A,B,C) activities from activity C.
--------------------------
Step 1 : Save A, B, C activity in static Activity Vector. Create Static class and create Activity Vector.

public class VARIABLES_STACK_RANJIT {
                 public static Vector<Activity> v_context = new Vector<Activity>();
}

Step 2 : Write following code in A,B,C activity
               i) VARIABLES_STACK_RANJIT.v_context.add(A.this);
               ii) VARIABLES_STACK_RANJIT.v_context.add(B.this);
               i) VARIABLES_STACK_RANJIT.v_context.add(C.this);

Step 3 : Write final code in D activity

Start loop and finish manually all saved activity.

                 for (int i = 0; i < VARIABLES_STACK.v_context.size(); i++) {
(VARIABLES_STACK.v_context.elementAt(i)).finish();
Log.e("Activity :" + i, "finished...");
}

---------------------------------------------------------------------------

Monday, February 4, 2013

Don't reload activity when orientation changes in an Android

Changes in an AndroidManifest.xml file
Set configChanges="----------" property in <activity> tag.

Example:
android:configChanges="orientation|screenSize"

If we use this property then do not reload activity after changing the orientation (Portrait/Landscape).

Thursday, January 31, 2013

Online Compiler for compile all languages code

Hello friends,

Very tedious task to install all programming languages editor in an machine..

Avoid above step if you have internet.
Check this link for online compilers...


1. http://codepad.org/
2. http://www.compileonline.com/compile_cpp_online.php