Hi Friends, if you like my blog please give your valuable comments it will help to improve my blog content and enthusiasm to write a lot in android World.

Tuesday, May 21, 2013

Display the path of selected Picture in gallery

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Gallery click = (Gallery) findViewById(R.id.gallery);

  final List<String> sdcard = ReadSDCard();
  click.setAdapter(new ImageAdapter(this, sdcard));
    
  click.setOnItemClickListener(new OnItemClickListener()
 {
      public void onItemClick(AdapterView<?> parent,
           View v, int position, long id) {
         Toast.makeText(Galleryy.this,
    (CharSequence)sdcard.get(position),
    Toast.LENGTH_LONG).show();
      }
  });
}


Friday, April 12, 2013

Disable screen lock in android


KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();


 androidmanifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>

Simple Alert Popup with Title, Message, Icon and Button

AlertDialog alertDialog = new AlertDialog.Builder(this).create();
 alertDialog.setTitle("Title");
 alertDialog.setMessage("Message");
 alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int which) {
 // TODO Add your code for the button here.
 } });
 // Set the Icon for the Dialog
 alertDialog.setIcon(R.drawable.icon);
alertDialog.show();

Android- Embed Google Map in Web View

 package com.example.androidwebmap;
import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class TestActivity extends Activity {

 WebView myWebView;

 String mapPath = "https://maps.google.com/?ll=37.0625,-95.677068&spn=29.301969,56.513672&t=h&z=4";

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  myWebView = (WebView)findViewById(R.id.mapview);
  myWebView.getSettings().setJavaScriptEnabled(true);
  myWebView.setWebViewClient(new WebViewClient());

  myWebView.loadUrl(mapPath);
 }

}

XML File


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

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

</LinearLayout>



Important:
- Permission of "android.permission.INTERNET" is need.








Wednesday, April 10, 2013

Autostart our application when android device start from bootup


when you power on the device open our application starts.
through receiver we can achieve this one .

Androidmenifest.xml
 <receiver android:enabled="true" android:name=".Startourapp"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED">

        <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

Startourapp.class

public class Startourapp extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
            Intent i = new Intent(context, MainActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               context.startActivity(i);  

    }

}

Thursday, February 7, 2013

Trick to get source code from APK file


Required software's and Tools

Get APK source code files for Windows
or
Get APK source code files for Mac OS X
or
Get APK source code files for Linux







Step 1. Rename the .apk file you wish to retrieve and change the extension to .zip. Then extract the file that it creates.
Step 2. Copy the contents of the dex2jar folder to the extracted folder to make it easier for yourself, and run:
dex2jar classes.dex
and copy the resulting “classes.dex.dex2jar.jar” into a new folder.
Step 3. Open up the Java Decompiler and drag “classes.dex.dex2jar.jar” into the window and then go to File > Save and save the source in a .zip file.
Step 4. Extract the saved .zip and copy the contents to a new folder somewhere. This will be where we keep your source code.
Step 5. Now, copy “framework-res.apk” and “yourapk.apk” to the APKTool folder. Then open a command prompt or Terminal window and type:
apktool if framework-res.apk
apktool d <yourapk.apk>
Step 6. Now just copy the contents of the resulting folder to the same place you copied the contents of “classes.dex.dex2jar.jar” earlier and voila, you have your source code. You may need to remove a couple of things as shown in the video, but your entire code should be there!

Import project into eclipse

Step By step

1. Navigate to Import section
2. Select ‘Existing Android project into workshop’ option under ‘Android’ section and click on ‘Next’
3. In the next screen browse and select the app folder, check the option ‘Copy project into workspace’.
4.App is imported successfully.

Hope this help you guys:)