Google provides the api for drawing the 3d piechart by just providing simple parameters of the chart one can very easily draw the piechart ,bargraph etc the chart will be displayed in the webview the code is shown bellow








package com.shir60bhushan.piechart;
 
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
 
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
 
public class Android3dPieChartActivity extends Activity {
  
 final static String urlGoogleChart 
  = "http://chart.apis.google.com/chart";
 final static String urlp3Api 
  = "?cht=p3&chs=400x150&chl=A|B|C&chd=t:";
  
 EditText inputA, inputB, inputC;
 Button generate;
 ImageView pieChart;
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        inputA = (EditText)findViewById(R.id.adata);
        inputB = (EditText)findViewById(R.id.bdata);
        inputC = (EditText)findViewById(R.id.cdata);
        generate = (Button)findViewById(R.id.generate);
        pieChart = (ImageView)findViewById(R.id.pie);
        generate.setOnClickListener(generateOnClickListener);
    }
     
    Button.OnClickListener generateOnClickListener
    = new Button.OnClickListener(){
 
  @Override
  public void onClick(View arg0) {
   // TODO Auto-generated method stub
   String A = inputA.getText().toString();
   String B = inputB.getText().toString();
   String C = inputC.getText().toString();
   String urlRqs3DPie = urlGoogleChart 
     + urlp3Api 
     + A + "," + B + "," + C;
    
   Bitmap bm3DPie = loadChart(urlRqs3DPie);
   if(bm3DPie == null){
    Toast.makeText(Android3dPieChartActivity.this,
      "Problem in loading 3D Pie Chart",
      Toast.LENGTH_LONG).show(); 
   }else{
    pieChart.setImageBitmap(bm3DPie); 
   }
  }};
   
 private Bitmap loadChart(String urlRqs){
  Bitmap bm = null;
  InputStream inputStream = null;
   
  try {
   inputStream = OpenHttpConnection(urlRqs);
   bm = BitmapFactory.decodeStream(inputStream);
   inputStream.close(); 
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace(); 
  }
   
  return bm; 
 }
      
 private InputStream OpenHttpConnection(String strURL) throws IOException{
  InputStream is = null;
  URL url = new URL(strURL);
  URLConnection urlConnection = url.openConnection();
        
  try{
   HttpURLConnection httpConn = (HttpURLConnection)urlConnection;
   httpConn.setRequestMethod("GET");
   httpConn.connect();
    
   if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
    is = httpConn.getInputStream();  
   } 
  }catch (Exception ex){
  }
   
  return is;  
 }
}
and the Xml file for this is as follows:


    

        

            

                
            
        

        

            

                
            
        

        

            

                
            
        

        
    




Do you know an android Apk can be completley reverse enginnered to get all source code from it


As the use of the mobile is getting more day by day so security is one of the important concern for mobile software an android application apk can be reverse engineered and we can retrieve whole code from the .apk which is harmful from security point of view so what is the solution for this?
how developer can assure the security of the software,for thisandroid has provided one tool called "progaurd"it is the tool which secures your code in .apk it becomes very very complex to reverse engineer the code


How to implement progaurd ?


Add the following line in that file
proguard.config=proguard.cfg (its default location of file)

If you have moved the location of file then give absolute path as,

proguard.config=/path/to/proguard.cfg

This is how your cfg file will look like.

-injars lib
-libraryjars ../../..//Android/android_sdk_mac_x86/add-ons/addon-google_apis-google-16

-optimizationpasses 5

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontnote
-verbose
-optimizations 

!code/simplification/arithmetic,!field/*,!class/merging/*


-dontwarn sun.misc.Unsafe, java.lang.management.ManagementFactory, org.codehaus.jackson.JsonParser, org.json.JSONObject, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.JsonFactory, com.google.common.collect.MinMaxPriorityQueue



-keep public class * extends android.app.Application

-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
    native;
}

-keepclasseswithmembers class * {


    public(android.content.Context, android.util.AttributeSet);

}

 -keepclasseswithmembers class * {

    public(android.content.Context, android.util.AttributeSet, int);
}

 -keepclassmembers class * extends android.app.Activity {

   public void *(android.view.View);
}

 -keepclassmembers enum * {

    public static **[] values();
    public static ** valueOf(java.lang.String);
}
 -keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;

}



package com.shir60bhushan.excelContacts.About_N_Help;
import com.shir60bhushan.excelContacts.R;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AppRater
{
 private final static String APP_TITLE    = "Battery Saver Widget";
 private final static String APP_PNAME    = "com.batterysaverwidget";
 static Typeface    tf;
 private final static int DAYS_UNTIL_PROMPT  = 3;
 private final static int LAUNCHES_UNTIL_PROMPT = 7;


 public static void app_launched(Context mContext)
 {
  tf = Typeface.createFromAsset(mContext.getAssets(), "Merienda-Regular.ttf");
  SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);

  if(prefs.getBoolean("dontshowagain", false))
  {
   return;
  }

  SharedPreferences.Editor editor = prefs.edit();

  // Increment launch counter
  long launch_count = prefs.getLong("launch_count", 0) + 1;
  editor.putLong("launch_count", launch_count);


 // Get date of first launch

  Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
  if(date_firstLaunch == 0)
  {
   date_firstLaunch = System.currentTimeMillis();
   editor.putLong("date_firstlaunch", date_firstLaunch);
  }


 // Wait at least n days before opening

  if(launch_count >= LAUNCHES_UNTIL_PROMPT)
  {
   if(System.currentTimeMillis() >= date_firstLaunch + (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000))
   {
    showRateDialog(mContext, editor);
  }
 editor.commit();
 }

 public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor)
 {
  final Dialog dialog = new Dialog(mContext);

 TextView tvTitle = new TextView(mContext);
  dialog.setTitle(" Rate " + APP_TITLE + "  ");

  LinearLayout ll = new LinearLayout(mContext);
  ll.setOrientation(LinearLayout.VERTICAL);

  TextView tv = new TextView(mContext);
  tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
  tv.setWidth(240);
  tv.setTextColor(Color.WHITE);
  tv.setPadding(4, 0, 4, 10);
  tv.setTypeface(tf);
  ll.addView(tv);


  Button b1 = new Button(mContext);

  //b1.setBackgroundResource(R.drawable.selector_buttons);
  b1.setText("Rate " + APP_TITLE);
  b1.setTypeface(tf, Typeface.BOLD);
 b1.setOnClickListener(new View.OnClickListener()
  {
   public void onClick(View v)
   {
    mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
    dialog.dismiss();
   }
  });
  ll.addView(b1);

  Button b2 = new Button(mContext);
  b2.setText("Remind me later");
  // b2.setBackgroundResource(R.drawable.selector_buttons);
  b2.setTypeface(tf, Typeface.BOLD);

  b2.setOnClickListener(new View.OnClickListener()
  {
   public void onClick(View v)
   {
    dialog.dismiss();
   }
  });
  ll.addView(b2);


  Button b3 = new Button(mContext);
  b3.setText("No, thanks");
  //b3.setBackgroundResource(R.drawable.selector_buttons);
  b3.setTypeface(tf, Typeface.BOLD);
  b3.setOnClickListener(new View.OnClickListener()
  {
   public void onClick(View v)
   {
    if(editor != null)
    {
     editor.putBoolean("dontshowagain", true);
     editor.commit();
    }
    dialog.dismiss();
   }
  });

  ll.addView(b3);
 dialog.setContentView(ll);
  dialog.show();
 }
}package com.shir60bhushan.excelContacts.About_N_Help;
import com.shir60bhushan.excelContacts.R;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AppRater
{
 private final static String APP_TITLE    = "Battery Saver Widget";
 private final static String APP_PNAME    = "com.batterysaverwidget";
 static Typeface    tf;
 private final static int DAYS_UNTIL_PROMPT  = 3;
 private final static int LAUNCHES_UNTIL_PROMPT = 7;


 public static void app_launched(Context mContext)
 {
  tf = Typeface.createFromAsset(mContext.getAssets(), "Merienda-Regular.ttf");
  SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);

  if(prefs.getBoolean("dontshowagain", false))
  {
   return;
  }

  SharedPreferences.Editor editor = prefs.edit();

  // Increment launch counter
  long launch_count = prefs.getLong("launch_count", 0) + 1;
  editor.putLong("launch_count", launch_count);


 // Get date of first launch

  Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
  if(date_firstLaunch == 0)
  {
   date_firstLaunch = System.currentTimeMillis();
   editor.putLong("date_firstlaunch", date_firstLaunch);
  }


 // Wait at least n days before opening

  if(launch_count >= LAUNCHES_UNTIL_PROMPT)
  {
   if(System.currentTimeMillis() >= date_firstLaunch + (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000))
   {
    showRateDialog(mContext, editor);
  }
 editor.commit();
 }

 public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor)
 {
  final Dialog dialog = new Dialog(mContext);

 TextView tvTitle = new TextView(mContext);
  dialog.setTitle(" Rate " + APP_TITLE + "  ");

  LinearLayout ll = new LinearLayout(mContext);
  ll.setOrientation(LinearLayout.VERTICAL);

  TextView tv = new TextView(mContext);
  tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
  tv.setWidth(240);
  tv.setTextColor(Color.WHITE);
  tv.setPadding(4, 0, 4, 10);
  tv.setTypeface(tf);
  ll.addView(tv);


  Button b1 = new Button(mContext);

  //b1.setBackgroundResource(R.drawable.selector_buttons);
  b1.setText("Rate " + APP_TITLE);
  b1.setTypeface(tf, Typeface.BOLD);
 b1.setOnClickListener(new View.OnClickListener()
  {
   public void onClick(View v)
   {
    mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
    dialog.dismiss();
   }
  });
  ll.addView(b1);

  Button b2 = new Button(mContext);
  b2.setText("Remind me later");
  // b2.setBackgroundResource(R.drawable.selector_buttons);
  b2.setTypeface(tf, Typeface.BOLD);

  b2.setOnClickListener(new View.OnClickListener()
  {
   public void onClick(View v)
   {
    dialog.dismiss();
   }
  });
  ll.addView(b2);


  Button b3 = new Button(mContext);
  b3.setText("No, thanks");
  //b3.setBackgroundResource(R.drawable.selector_buttons);
  b3.setTypeface(tf, Typeface.BOLD);
  b3.setOnClickListener(new View.OnClickListener()
  {
   public void onClick(View v)
   {
    if(editor != null)
    {
     editor.putBoolean("dontshowagain", true);
     editor.commit();
    }
    dialog.dismiss();
   }
  });

  ll.addView(b3);
 dialog.setContentView(ll);
  dialog.show();
 }
}