Thursday, 19 December 2013

Remove non Ascii characters from strings

public class Sample {
    public static void main(String a[]){
        String str = "GHj��PL����AM�";
        System.out.println(str);
        str = str.replaceAll("[^\\p{ASCII}]", "");
        System.out.println("After removing non ASCII chars:");
        System.out.println(str);
    }
}
 System.out.println("here dec after con is "+decryptedContent.replaceAll("[^\\p{ASCII}]", "").trim());
OUTPUT
After removing non ASCII chars:
GHjPLAM 



Remove HTML Tags

public class HtmlTagRemover {
    public static void main(String a[]){
        String text = "<B>Remove tags<\\B>";
        System.out.println(text);
        text = text.replaceAll("\\<.*?\\>", "");
        System.out.println(text);
    }
}


OUTPUT
 "<B>Remove tags<\B>
Remove tags
 

  public class multipleSpaces {
    public static void main(String[] args) {
      
                String str = "String    With Multiple      Spaces";
                StringTokenizer st = new StringTokenizer(str, " ");
                StringBuffer sb = new StringBuffer();
                while(st.hasMoreElements()){
                    sb.append(st.nextElement()).append(" ");
                }
                System.out.println(sb.toString().trim());
            }
        }

 

 

 

Tuesday, 19 November 2013

Android pushNotification badge ICON similar to IOS


1.    Create a appwidget-provider xml name it as widget_badge_icon.xml and add it in xml folder
2.    Create a widget_badge_layout .xml as per need.
3.    Create a receiver in manifest file.
4.    Create BadgeNotificationWidget Class:


package com.example.testwidget;

import java.util.Timer;

import java.util.TimerTask;

import android.app.IntentService;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;

/**
 * BadgeService is a worker thread used to send the badge number as a broadcast
 * message to change the app icon.
 *
 *
 */
public class BadgeService extends IntentService {

    int count = 0;

    Timer timer;

    int randomNo = 10;

    public BadgeService() {
        super("BadgeService");
        timer = new Timer();
    }

    /**
     * This method is invoked on the worker thread with a request to process.
     */
    @Override
    protected void onHandleIntent(final Intent intent) {

        RemoteViews remoteView = new RemoteViews(getApplicationContext()
                .getPackageName(), R.layout.widget_badge_layout);

        ComponentName componentName = new ComponentName(
                getApplicationContext(), BadgeNotificationWidgetActivity.class);

        AppWidgetManager appWidgetManager = AppWidgetManager
                .getInstance(getApplicationContext());

        Log.d("BadgeNotificationWidgetActivity", "BadgeService randomNo"
                + randomNo);
        if (randomNo == 0) {
            remoteView.setViewVisibility(R.id.badgeNum, View.GONE);
        } else {
            remoteView.setViewVisibility(R.id.badgeNum, View.VISIBLE);
        }

        remoteView.setTextViewText(R.id.badgeNum, String.valueOf(randomNo));
        // apply changes to widget
        appWidgetManager.updateAppWidget(componentName, remoteView);

    }
}






package com.example.testwidget;




import android.os.Bundle;

import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

   
   
    @Override
    protected void onStart() {
        super.onStart();
        startService(new Intent(this, BadgeService.class));
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}




package com.example.testwidget;

import android.appwidget.AppWidgetManager;

import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.util.Log;
import android.widget.RemoteViews;

public class BadgeNotificationWidgetActivity extends AppWidgetProvider {

   

   

   

}





<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testwidget"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/image"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testwidget.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       
        <service android:name=".BadgeService" >
        </service>
       
       
         <receiver
            android:name="com.example.testwidget.BadgeNotificationWidgetActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_badge_icon" />
        </receiver>
    </application>

</manifest>



badge_circle.xml


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >

    <corners android:radius="10dip" />

    <solid android:color="#F00" />

    <stroke
        android:width="5dp"
        android:color="#FFF" />

    <padding
        android:bottom="8dp"
        android:left="10dp"
        android:right="10dp"
        android:top="8dp" />

</shape>

widget_badge_icon.xml


<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/widget_badge_layout"
    android:minHeight="40dp"
    android:minWidth="40dp"
    android:updatePeriodMillis="30000" >

</appwidget-provider>


Following link contains source code   Sample Source

HTML Report using Lint

The following command is used to generate lint error report in android

On the command prompt redirect to the android---->sdk---->tools
Then type lint --html --sample pathoftheproject

HTML report gets generated in the sdk--->tools with the name --sample



TreeMap is an example of a SortedMap, which means that the order of the keys can be sorted, and when iterating over the keys, you can expect that they will be in order.

HashMap on the other hand, makes no such guarantee. Therefore, when iterating over the keys of a HashMap, you can't be sure what order they will be in.

HashMap will be more efficient in general, so use it whenever you don't care about the order of the keys.


Daemon thread in Java are those thread which runs in background and mostly created by JVM for performing background task like Garbage collection and other house keeping tasks. Difference between Daemon and Non Daemon(User Threads)  is also an interesting multi-threading interview question, which asked mostly on fresher level java interviews. In one line main difference between daemon thread and user thread is that as soon as all user thread finish execution java program or JVM terminates itself, JVM doesn't wait for daemon thread to finish there execution. As soon as last non daemon thread finished JVM terminates no matter how many Daemon thread exists or running inside JVM.


Read more: http://javarevisited.blogspot.com/2012/03/what-is-daemon-thread-in-java-and.html#ixzz2pyQBJtx4


 1) JVM doesn't wait for any daemon thread to finish before existing.

2) Daemon Thread are treated differently than User Thread when JVM terminates, finally blocks are not called, Stacks are not unwounded and JVM just exits.

Read more: http://javarevisited.blogspot.com/2012/03/what-is-daemon-thread-in-java-and.html#ixzz2pyR6S9Kt
 

Friday, 8 November 2013

Package name and App name

System.out.println("print here "+getApplicationContext().getPackageName());
        System.out.println("print here complete name "+getApplicationContext().getPackageName().concat("."+getApplicationContext().getString(getApplicationContext().getApplicationInfo().labelRes)));

Wednesday, 30 October 2013

Check for Wifi and see whether internet is reachable or not

package com.example.checkinternetconnection;

import java.io.IOException;

import java.net.HttpURLConnection;
import java.net.URL;
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {
   
   
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        StrictMode.setThreadPolicy(policy);
        ConnectivityManager cm =
                (ConnectivityManager)getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
       
        NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
        boolean isConnected = activeNetwork != null &&
                              activeNetwork.isConnectedOrConnecting();
        System.out.println("internet connection is "+isConnected);
       
       
         boolean isReachable = false;
       
         if (activeNetwork != null && activeNetwork.isConnected()) {
                // Some sort of connection is open, check if server is reachable
                try {
                    URL url = new URL("http://www.google.com");
                    HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
                    urlc.setRequestProperty("User-Agent", "Android Application");
                    urlc.setRequestProperty("Connection", "close");
                    urlc.setConnectTimeout(30 * 1000);
                    urlc.connect();
                    isReachable = (urlc.getResponseCode() == 200);
                    System.out.println("internet reachable true");
                } catch (IOException e) {
              
                   
                      System.out.println("internet reachable false"+e.getMessage());
                    Log.e("internet", e.getMessage());
                }
            }
       
       
       
       
       
           
       
       
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


Manifest Changes :
-----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.checkinternetconnection"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.checkinternetconnection.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

</manifest>

Monday, 21 October 2013

Export Jar File In java



Push Notifications

Introduction

Sample App which registers with GCM and receives device token from it 

GCM Service Class

import android.app.Notification;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.google.android.gcm.GCMBaseIntentService;

public class GCMIntentService extends GCMBaseIntentService {

    private static String TAG = GCMIntentService.class.getName();
    /**
     * Intent used to display a message in the screen.
     */
    public static final String DISPLAY_MESSAGE_ACTION = "com.google.android.gcm.demo.app.DISPLAY_MESSAGE";

    /**
     * Intent's extra that contains the message to be displayed.
     */
    public static final String EXTRA_MESSAGE = "message";

    public GCMIntentService() {
        super("project no");
    }

    @Override
    protected void onError(Context context, String errorId) {
        Log.i(TAG, "Received message " + errorId);
    }

    @Override
    protected void onMessage(Context context, Intent intent) {
        Log.i(TAG, "Received message");
        // String message = getString(R.string.gcm_message);
        String message = intent.getExtras().getString("message");
        displayMessage(context, message);
        // notifies user
        generateNotification(context, message);
    }

    @Override
    protected void onRegistered(Context context, String registrationId) {
        Log.i(TAG, "Device registered: regId = " + registrationId);
    }

    @Override
    protected void onUnregistered(Context context, String registrationId) {
        // TODO Auto-generated method stub

    }

    private void displayMessage(Context context, String message) {
        Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
        intent.putExtra(EXTRA_MESSAGE, message);
        context.sendBroadcast(intent);
    }

    /**
     * Issues a notification to inform the user that server has sent a message.
     */
    private static void generateNotification(Context context, String message) {

        int icon = R.drawable.ic_launcher;
        long when = System.currentTimeMillis();
        NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);
        String title = context.getString(R.string.app_name);
        Intent notificationIntent = new Intent(context, TimerScreen.class);
        // set intent so it does not start a new activity
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent intent =PendingIntent.getActivity(context, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notificationManager.notify(0, notification);

    }
}


BroadCast Receiver

package com.example.responsetest;

import android.app.Activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class TimerScreen extends Activity {
    /**
     * Intent's extra that contains the message to be displayed.
     */
    public static final String EXTRA_MESSAGE = "message";

    private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String newMessage = intent.getExtras().getString(EXTRA_MESSAGE);
        }
    };

}


MainActivity

package com.example.responsetest;

import com.google.android.gcm.GCMRegistrar;


import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        // Make sure the device has the proper dependencies.
                GCMRegistrar.checkDevice(this);

                // Automatically registers application on startup.
                GCMRegistrar.register(this, "projectno");

                final String regId = GCMRegistrar.getRegistrationId(this);
                Log.d("GCMIntentService", "GCMIntentService " + regId);
               
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

Client Jar

GCM Client jar is needed

Thursday, 17 October 2013

java handling string and splitting it in key-value



public class StringSplit {
            public static void main(String[] args) {

                        String assetClasses = "name = Gold: price = Stocks:icome = Fixed :********";
                        assetClasses.replace("*", "");
                        String[] splits = assetClasses.split(":");
                        HashMap<String, String> hash = new HashMap<String, String>();

                        System.out.println("splits.size: " + splits.length);
                        for (String asset : splits) {
                                    if (asset.indexOf("=") != -1) {
                                                String[] splitstwo = asset.split("=");

                                                //if ((splitstwo.length == 2))
                                                            hash.put(splitstwo[0], splitstwo[1]);

                                                for (String splitasset : splitstwo) {

                                                            System.out.println(splitasset);
                                                }
                                    }
                                    System.out.println(asset);
                                    System.out.println(hash);
                        }

            }

}

Tuesday, 24 September 2013

Calling other App from one App

package com.example.testintaller;

import android.app.Activity;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn = (Button) findViewById(R.id.button1);

        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

               

                   
                     Intent intent = new Intent(Intent.ACTION_MAIN);
                     intent.setClassName("package", "package.classname");
                     intent.putExtra("name", "xxx");
                     intent.putExtra("password", "yyyy");
                    startActivity(intent);
                   
           

            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


Note : Activity class of ther App which you are calling should be exported i,e in manifest we should give as android:exported = "true"

Tuesday, 3 September 2013

CustomView (accessing attrs.xml)

package com.example.customviewsecondexampkle;

import android.os.Bundle;

import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


package com.example.customviewsecondexampkle;

import android.content.Context;

import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.TextView;

public class ViewV extends TextView
{
    public ViewV(Context ctx, AttributeSet attrs)
    {
        super(ctx, attrs);

        TypedArray array = ctx.obtainStyledAttributes(attrs, R.styleable.CustomAttrs);
        String text = array.getString(R.styleable.CustomAttrs_xattr);
       
        if(text != null)
        {
          
        }
        array.recycle();
    }

}

activity_main.xml

<LinearLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res/com.example.customviewsecondexampkle"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >

    <com.example.customviewsecondexampkle.ViewV
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           app:xattr="testing"  />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

</LinearLayout>

attrs.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="CustomAttrs">
        <attr name="xattr" format="string" />
         <attr name="labelColor" format="color"/>
   
    </declare-styleable>
</resources>

Saturday, 31 August 2013

android customised dialogue with text view checkbox

package com.example.checkedit;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    private static final String PREFS_NAME = "CheckBoxState";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
       
        customAlertdialog();
   
    }

       public void customAlertdialog(){

            //Inflate layout

            LayoutInflater inflater = getLayoutInflater();

            View dialoglayout = inflater.inflate(R.layout.yourview, (ViewGroup) findViewById(R.id.yourview_root));

            // set data in textview

            TextView text1 = (TextView)dialoglayout.findViewById(R.id.text1);
            final CheckBox che = (CheckBox)dialoglayout.findViewById(R.id.checkBox1);

            text1.setText("Terms and Conditions");
            text1.setOnClickListener(new OnClickListener() {
               
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                   
                     Toast.makeText(getApplicationContext(), "textview msg", Toast.LENGTH_SHORT).show();
                   
                }
            });

            //display alertdialog

            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            builder.setView(dialoglayout).setTitle("Your title")

            .setCancelable(false)

            .setNeutralButton("Close", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {

               
                SharedPreferences settings = getSharedPreferences(
                        PREFS_NAME, 0);
                SharedPreferences.Editor editor = settings.edit();
                editor.putString("skipMessage", String.valueOf(che.isChecked()));
               
                // Commit the edits!
                editor.commit();
            dialog.cancel();

            }

            });

            AlertDialog alert = builder.create();

           
            SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
            String skipMessage = settings.getString("skipMessage", "NOT checked");
            System.out.println("ischeck is "+che.isChecked());
           
           
            if (!skipMessage.equals("true")) {

                alert.show();

            }
        

            }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


activity_main.xml

 

<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>


yourview.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/yourview_root" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/checkBox1"
        android:layout_alignBottom="@+id/checkBox1"
    android:layout_toRightOf="@+id/checkBox1"
        android:text="Do not show again" />

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="18dp"
        android:text="TextView1" />

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/text1"
        android:layout_marginTop="20dp" />

    </RelativeLayout>
   

Second highest element in array

import java.util.Arrays;


public class secondlargest {
   
    public static void main(String[] args) {
        int a[] = { 0,80,200,500,900};
        Arrays.sort(a);
        for(int i=0;i<a.length;i++)
        {
        System.out.println("after sorting "+a[i]);
        }

        int largest = a[0];
        int secondlargest = a[0];
        int cmp = 0;
        for (int i = 0; i < a.length; i++) {

            if (largest < a[i]) {
                secondlargest = largest;
                largest = a[i];
               
               
            }
           
            else if(a[i]>secondlargest)
            {
                secondlargest = a[i];
            }

           

        }
        System.out.println("sec lar is "+secondlargest);
        System.out.println("lar is  " + largest);

    }

}

Monday, 12 August 2013

display metrics android(device width zero initially)

Plz add the following to the application oncreate method to get width and height of device




        ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
          .getDefaultDisplay().getMetrics(displayMetrics);


DisplayMetrics met =  new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(met);
        System.out.println("here  "+met.widthPixels);
        System.out.println("here height is "+met.heightPixels);

Tuesday, 30 July 2013

Transperency in android canvas

Paint Paint = new Paint();
    Paint.setColor(Color.argb(50, 128, 24, 24));
    Paint.setStyle(Style.FILL);   
    Paint.setAntiAlias(true);


50 is the alpha parameter based on which transperency parameter will vary

Thursday, 25 July 2013

Complete excel to strings.xml and localised.txt is stored in google site(includes arrays also)


Java while running some external library file is missing

Do the following

Go to Project->Properties->Java Build Path than select Order and export tab. Set android-support-v4.jar library checked and up it into top of the list. And clean and rebuild..It works for most of the cases


External library is android-support-v4.jar in this case

Android header footer with scrollable listview



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_color" >

    <include
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="119dp"
        layout="@layout/header_text" />

    <include
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        layout="@layout/mnbuttons"
        android:id="@+id/footer"/>
    <ListView
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/footer"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="73dp" >
    </ListView>

</RelativeLayout>

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...