Thursday, 10 April 2014

Android- To get all version history and creation date and time for a particular APK.

4 comments
In this post you will have to find how to get the all version details and date of creation of particular APK file.

So from that you can access the details of one of your app with other app.Its very easy to do this just follow the following steps.


Step 1) Add your apk(that you want the details) in your sdcard or the folder you want.

Step 2) Add the following code in your activity.

ZipFile zf;

final PackageManager pm = getPackageManager();

      //Name of your apk file that you want details
String apkName = "yourappname.apk";    

     //Give it to the path of your apk file 
String fullPath = Environment.getExternalStorageDirectory() 
                                       + "/"  + apkName;

PackageInfo info = pm.getPackageArchiveInfo(fullPath, 0);

try {
zf = new ZipFile(fullPath);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

ZipEntry ze = zf.getEntry("classes.dex");
long time = ze.getTime();
String s = SimpleDateFormat.getInstance().format(
new java.util.Date(time));

Step 3)Just display your all details.
              
         Toast.makeText(this,"VersionCode : " + info.versionCode + ", 
                              VersionName : " + info.versionName + ", 
                              App Creation Date : " + s,

                        Toast.LENGTH_LONG).show();


Thanks..Android rocks..:)


Read full post »

Wednesday, 12 March 2014

Display list of files with particular extension like(.txt,.png,etc)

0 comments
In this post we look into how to get filtered list with particular extension from sdcard or anywhere.

Please follow the below steps to do this:-

1)Write a method like following which simply returns a filtered list so you will used these anywhere or display this in a list view.

public ArrayList<String> File_Select()
{
      File dir_home = new File(Environment.getExternalStorageDirectory(), "");
      ArrayList<String> filteredlist = new ArrayList<String>();
     
      if (dir_home .listFiles(new NameFilter()).length > 0) 
     {
 for (File file : (dir_home .listFiles(new NameFilter())) 
           {
                   filteredlist .add(file.getName().substring(0, (file.getName().length() - 4)));        
           }
    }
      
       return filteredlist ;
}


2)Finally,write a class that will perform this filtering

class NameFilter implements FilenameFilter 
{
public boolean accept(File dir, String name) 
        {
           return (name.endsWith(".txt") ||name.endsWith(".TXT"));
}
}

Done.Thanks..Android Rocks..:)
Read full post »

Monday, 10 February 2014

Open an pop-up window with animation.

0 comments
1)First you have to create a method that display an pop-up.

         public void display_popup() {
                LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView= layoutInflater.inflate(R.layout.follow_leader, null);

PopupWindow popupWindow = new PopupWindow(popupView,                                                                                     LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);
popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
         }

2)Next you have to write an animation XML for your pop-up inside res/anim folder.

fade_in.xml
                <set xmlns:android="http://schemas.android.com/apk/res/android"
                                android:fillAfter="true">
                   <alpha android:fromAlpha="0.0"
                               android:toAlpha="1.0"
                              android:duration="3000"/> //Time in milliseconds
                </set>
fade_out.xml
              <set xmlns:android="http://schemas.android.com/apk/res/android"
                    android:fillAfter="true" >
                   <alpha  android:duration="3000"
                               android:fromAlpha="1.0"
                              android:toAlpha="0.0" />
                </set>

3)After that you have to write an style for your pop-up inside values/style.xml file.

          <style name="PopupWindowAnimation">
                 <item name="android:windowEnterAnimation">@anim/fade_in</item>
                  <item name="android:windowExitAnimation">@anim/fade_out</item>
          </style>

4)Finally you set this style to pop-up by writing the below in your display_popup() method.

          popupWindow.setAnimationStyle(R.style.PopupWindowAnimation);

Done..android rocks..
Read full post »

Monday, 13 January 2014

Animation in Android

4 comments
In this post you find the animation for transition between two screens.

First you have to create anim folder inside /res folder.and write the following XML in that.

slide_in.xml
<?xml version="1.0" encoding="utf-8"?>
<translate 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:duration="@android:integer/config_longAnimTime" 
      android:fromXDelta="100%p" 
      android:toXDelta="0%p">
</translate>

slide_out.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:duration="@android:integer/config_longAnimTime" 
      android:fromXDelta="0" 
      android:toXDelta="-100%p">
</translate>

fade_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" 
     android:fillAfter="true">
     <alpha android:fromAlpha="0.0" 
            android:toAlpha="1.0"
            android:duration="5000"/> 
</set>

fade_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >
   <alpha
        android:duration="5000"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />
</set>

slide_in_opp.xml
<?xml version="1.0" encoding="utf-8"?>
<translate 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:duration="@android:integer/config_longAnimTime" 
      android:fromXDelta="-100%p" 
      android:toXDelta="0%p">
</translate>

slide_out_opp.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:duration="@android:integer/config_longAnimTime" 
      android:fromXDelta="0" 
      android:toXDelta="100%p">
</translate>

Next,You just include this following in your java code to use this animations.

       overridePendingTransition(R.anim.slide_in, R.anim.slide_out);

Done..
Thanks.
Read full post »
 

Copyright © Unique Android Tutorial.. Design by Free CSS Templates | Blogger Theme by BTDesigner | Powered by Blogger