RSS

Remove app from recent apps programmatically

Add New Activity:

public class ExitActivity extends Activity{
    @Override protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        if(android.os.Build.VERSION.SDK_INT >= 21){
            finishAndRemoveTask();
        }
        else{
            finish();
        }
    }

    public static void exitApplicationAnRemoveFromRecent(Context mContext){
        Intent intent = new Intent(mContext, ExitActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK  | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_ANIMATION);
        mContext.startActivity(intent);
    }
}

Now exit from other Activity:

@Override
public void onBackPressed() {
 ExitActivity.exitApplicationAnRemoveFromRecent(mContext);
 super.onBackPressed();
}

Disclaimer: Hiren Patel (http://stackoverflow.com/questions/13385289/remove-app-from-recent-apps-programmatically)

 
2 Comments

Posted by on September 1, 2016 in Android Source Code

 

Android Debug Bridge (adb) Wireless Debugging Over Wi-Fi

Screenshot_2016-09-02-11-01-50

  1. Open cmd
    go to path till
    C:\Users\servpro.nikhil\AppData\Local\Android\sdk\platform-tools
  2. Type
    adb usb
  3. Type
    adb devices
  4. Type
    adb tcpip 5556
  5. Type
    adb connect <Your device IP address>
    Note: To check device IP address go to settings > About Phone > Status > IP address
    You will find status ad Connected to
  6. Remove USB and Enjoy
 
Leave a comment

Posted by on August 30, 2016 in Android Source Code

 

How to do clear data through app – Android

public void clearApplicationData()
{
File cache = getCacheDir();
File appDir = new File(cache.getParent());
if (appDir.exists())
{
String[] children = appDir.list();
for (String s : children)
{
if (!s.equals("lib"))
{
deleteDir(new File(appDir, s));
Log.i("TAG", "**************** File /data/data/APP_PACKAGE/" + s + " DELETED *******************");
}
}
}
}

public static boolean deleteDir(File dir)
{
if (dir != null &amp;&amp; dir.isDirectory())
{
String[] children = dir.list();
for (int i = 0; i &lt; children.length; i++)
{
boolean success = deleteDir(new File(dir, children[i]));
if (!success)
{
return false;
}
}
}
return dir.delete();
}

 
Leave a comment

Posted by on April 26, 2016 in Android Source Code

 

ViewPager update fragment on swipe – Android

1) Attach the Listener:

mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(final int i, final float v, final int i2) {
            }
            @Override
            public void onPageSelected(final int i) {
                YourFragmentInterface fragment = (YourFragmentInterface) mPagerAdapter.instantiateItem(mViewPager, i);
                if (fragment != null) {
                    fragment.fragmentBecameVisible();
                } 
            }
            @Override
            public void onPageScrollStateChanged(final int i) {
            }
        });

2) This is your Interface:

public interface YourFragmentInterface {
    void fragmentBecameVisible();
}

3) Change your fragments so they implement this:

public class YourLovelyFragment extends Fragment implements YourFragmentInterface {

4) Implement the interface in the fragment

@Override
public void fragmentBecameVisible() {
    // You can do your animation here because we are visible! (make sure onViewCreated has been called too and the Layout has been laid. Source for another question but you get the idea.
}
 
Leave a comment

Posted by on February 5, 2016 in Android Source Code

 

Handle onKeyListener in Fragment – Android

public static class MyFragment extends Fragment {

        @Override
        public void onResume() {
            super.onResume();
            getView().setFocusableInTouchMode(true);
            getView().requestFocus();
            getView().setOnKeyListener(new View.OnKeyListener() {
                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    //YOUR CODE
                    return false;
                }
            });
        }
    }
 
Leave a comment

Posted by on February 3, 2016 in Android Source Code

 

error validating location org.apache.subversion.javahl.clientexception

Just do changes suggested below to get it resolve:
In eclipse: Window > Preference > Team > SVN: select SVNKit (Pure Java) instead JavaHL(JNI)

 
Leave a comment

Posted by on January 29, 2016 in Android Source Code

 

Setup SVN in android studio

1. Download Subversion 1.8.13 ( 1.8 ) Download link ( https://www.visualsvn.com/downloads/ )
2. Unzipped in a folder. Find folder “bin” inside it.
3. Go to settings – > Version control -> Subversion
Don’t check Enable interactive mode if that option presnt under Use command line client option
4. Copy the url of your downloaded svn.exe that is in bin folder that you have downloaded.
Don’t forget to give the end name like svn.exe last as per image.
5. Apply -> Ok
6. Restart your android studio now.
7. Again Go to VCS > Enable Version Control Integration
8. Select Subversion > 1.8 plugin > Click OK
9. To checkout a project, choose “VCS” => “Checkout from Version Control” => “Subversion”
10. Select the same project where you want to checkout and click OK
11. Restart the eclipse and find all actions related to SVN like checkout/checkin in Android Studio

 
Leave a comment

Posted by on December 20, 2015 in Android Source Code