Integrate BitBucket Plug-in Android Studio

You can push project to Bit Bucket without using Terminal in Android Studio. To do that you need a Bitbucket plug-in.

Install BitBucket Plug-in

You can download BitBucket plugin from this link. After downloading zip file don’t unzip it. Goto Android Studio, press Ctrl+Alt+S, and search for Plugins in left panel. You will see Plugins tab in right panel.

as_bb_plugin

Click on Install plugin from disk,

as_bb_plugin-1

Select downloaded BitBucket zip file and Click on Apply,

BitBucket Plug-in

It’ll ask to restart Android Studio. Click Restart button.

After restarting, Your BitBucket Plug in is installed and ready to use. Now to start Push all your project to BitBucket.

Goto- VCS menu-> and select Enable Version Control Integration.

as_bb_plugin-3

You’ll be prompted to select Version control system for the project root, here select Git as Bit Bucket uses git system

as_bb_plugin-4

Now Goto, BitBucket website and Create a new repository with same name as project.

as_bb_plugin-5

You’ll see Command line syntax to init push code. Just copy the bitbucket origin Url as shown below.

as_bb_plugin-6

Now Goto AndroidStudio, select project and Git->Add as shown below

as_bb_plugin-9

And then Commit the changes as shown below.

as_bb_plugin-8

Enter initial Comment for project and then select Commit and Push as shown below.

as_bb_plugin-10

Here, You’ll ask to define remote,

as_bb_plugin-11

Click on it and Enter URL that we copied from Bit Bucket command line syntax.

as_bb_plugin-12

You’ll be able to Push code to the repository. Click on Push button

as_bb_plugin-13

Now Go to, Bit bucket website you’ll see project files Committed to your repository.

as_bb_plugin-14

That’s it. You just Pushed all your Project to Bit bucket without using Terminal window.

Hope it helps somebody.

Cheers.

You may also interested in

Beautiful messages collected

 ****9 BEAUTIFUL MESSAGES!!****

BEAUTIFUL MESSAGES

  1. Stay away from anger, it hurts only you.
  2. If you are right then there is no need to get angry, and if you are wrong then you don’t have any right to get angry.
  3. Patience with family is love, Patience with others is respect. Patience with self is confidence and Patience with GOD is faith.
  4. Never think hard about the PAST, It brings tears. Don’t think more about the FUTURE, It brings fears. Live this moment with a smile, it brings cheers.
  5. Every test in our life makes us bitter or better, every problem comes to make us or break us, The choice is ours whether we become victims or victorious.
  6. Beautiful things are not always good but good things are always beautiful.
  7. Do you know why God created gaps between fingers? So that someone who is special to you comes and fills those gaps by holding your hand forever.
  8. Happiness keeps you sweet so try n be as happy from within as possible.
  9. God has sent us all in pairs, someone somewhere is made for u. So wait for the right time n right moment.

copied message 🙂

You may be also interested in

 

Create new Class extends a SuperClass- Android Studio

In Android studio, If you want to create a new Class extends a SuperClass, built-in menu doesn’t provide option for it.

Create a Class extends a SuperClass

Where as you can only Create a new Class and then manually write down extends Superclass.

as_file1
Image 1
as_file1-2
Image 2

To add Create new Class which extends a SuperClass, you need to Create a new Template

Press Ctrl+Alt+S to open Settings  window, here search for File and Code Templates

as_file1-3
Image 3

Click + button to add new template, give a name as Inheritance(you can give any name) and write this below code

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != “”)package ${PACKAGE_NAME};#end
#parse(“File Header.java”)
public class ${NAME} extends ${SUPERCLASS} {
}

Apply it and the Click Ok button. as shown below

as_file1-4
Image 4

Now go to project and try to create new class as shown Image 1 above..

and  you’ll see newly added template in dropdown as shown below.

as_file1-5

Select it and then you’ll be asked to enter Super class name. Enter your Super class name.

SuperClass

That’s it.

You’ll see new Class created with SuperClass.

Hope it helps somebody.

You may also interested in

 

Gradle DSL method not found – Android Studio

After importing Eclipse project to Android Studio. When you run the project, you may see following error message as, Gradle DSL not found: ‘android()’

Gradle DSL

Solution to fix this Gradle DSL method issue

open Top-level build.gradle file of the project

as_gbuild_file

And remove the following code lines.

android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
}

And then click Sync menu button, fixes the issue.

sync

And another possible issue is,

Gradle DSL method not found: ‘runProguard()’

At times when you import a downloaded sample project in to Android Studio, see following error message as, Gradle DSL not found: ‘runProguard()’

app_gradlefile-2

Solution to fix this Gradle DSL method issue

open app’s build.gradle file of the project

app_gradlefile

In this file you can see following code snippet

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

In the above code runProguard false causing the issue. Change that line to

minifyEnabled false

Now click Sync menu button, issue will be fixed. I see the reason for this is runProguard has been renamed to minifyEnabled in version 0.14.0 or more in Gradle.

Hope it helps somebody. 😎

You may be also interested in

Create Rounded Shapes to apply Button background dynamically

Create Rounded Shapes with colours, and apply Button stateslist as background dynamically

While working on applying dynamic themes to app screens, I happen to work on applying Rounded Shapes with the colours dynamically, to display button states (i.e. default, pressed or focused etc) and also Text colors based on the colour codes in API response.

Rounded Shapesrounded_gray

below is the sample XML API response which shows color codes and XML data.

XML Color codes

 <!-- sample xml data -->
<DefBtnColour>#24014c</DefBtnColour>
<SelBtnColour>#5656ff</SelBtnColour>
<DefBtnFontColour>#afdbb6</DefBtnFontColour>
<SelBtnFontColour>#aa0197</SelBtnFontColour>

Applying shapes and button colour states is easy by creating a selector xml file in drawable folder. but applying dynamically need some more insight to implement in code.

Here is the code snippet… for it

First implemented two rounded shapes with <DefBtnColour> and <SelBtnColour> colours data, using ShapeDrawable class.

Rounded Shapes drawables using ShapeDrawable class

float[] radii = new float[8];
radii[0] = getResources().getDimension(R.dimen.spacing_10); //spacing_10 is 10dp
radii[1] = getResources().getDimension(R.dimen.spacing_10);
radii[2] = getResources().getDimension(R.dimen.spacing_10);
radii[3] = getResources().getDimension(R.dimen.spacing_10);

radii[4] = getResources().getDimension(R.dimen.spacing_10);
radii[5] = getResources().getDimension(R.dimen.spacing_10);
radii[6] = getResources().getDimension(R.dimen.spacing_10);
radii[7] = getResources().getDimension(R.dimen.spacing_10);

ShapeDrawable selShape = new ShapeDrawable();
selShape.setShape(new RoundRectShape(radii, null, null));
selShape.getPaint().setColor(selectedColour);

ShapeDrawable defShape = new ShapeDrawable();
defShape.setShape(new RoundRectShape(radii, null, null));
defShape.getPaint().setColor(defaultcolour);

now add these shapes to the StateListDrawable for default and pressed states..

StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] {android.R.attr.state_pressed}, selShape);
stateListDrawable.addState(new int[] {}, defShape);

now you can return this stateListDrawable object to apply button background drawable.

whole code snippets is below

 //step 1
protected StateListDrawable applyButtonSelector(int defaultcolour,int selectedColour){
    float[] radii = new float[8];
    radii[0] = getResources().getDimension(R.dimen.spacing_10);
    radii[1] = getResources().getDimension(R.dimen.spacing_10);
    radii[2] = getResources().getDimension(R.dimen.spacing_10);
    radii[3] = getResources().getDimension(R.dimen.spacing_10);

    radii[4] = getResources().getDimension(R.dimen.spacing_10);
    radii[5] = getResources().getDimension(R.dimen.spacing_10);
    radii[6] = getResources().getDimension(R.dimen.spacing_10);
    radii[7] = getResources().getDimension(R.dimen.spacing_10);

    ShapeDrawable selShape = new ShapeDrawable();
    selShape.setShape(new RoundRectShape(radii, null, null));
    selShape.getPaint().setColor(selectedColour);

    ShapeDrawable defShape = new ShapeDrawable();
    defShape.setShape(new RoundRectShape(radii, null, null));
    defShape.getPaint().setColor(defaultcolour);

    StateListDrawable stateListDrawable = new StateListDrawable();
    stateListDrawable.addState(new int[] {android.R.attr.state_pressed}, selShape);
    stateListDrawable.addState(new int[] {}, defShape);
    return stateListDrawable;
}

apply to button background as below

//step 2
themeBtn.setBackgroundDrawable(applyButtonSelector(convertToColorInt(DefaultButtonColour), convertToColorInt(SelectedButtonColour)));

below is the code to convert response colour code text to integer colour code

public static int convertToColorInt(String argb) throws IllegalArgumentException {
   if (!argb.startsWith(HASH)) {
      argb = HASH + argb;
   }
   return Color.parseColor(argb);
}

with this code (step 1,2) you can see,  shape and states drawable applied to button dynamically.

To apply ColorStates for button text you can see this post or SO ref link.

Hope this helps somebody…

ref links: http://stackoverflow.com/a/16502692/341443
http://stackoverflow.com/a/5963179/341443

🙂

You may be also interested in

 

Android Studio ADB wipes out logcat quickly when app crashes

Android Studio ADB wipes out logcat quickly

At time we may face this kind of annoying issue. In Android Studio, in Android tab ADB wipes out log cat data quickly when app crashes. And makes us not able to find out the code issue.

wipes out

To solve this issue, in Android tab on right side you can see dropdown to select the log filter

logcat2

Select Edit Filter Configuration, and you will see this window

logcat3

In this window, set your application Package Name as shown in  above image. You can set any Filter Name text. and Click OK.

Now, if app crashes, it will show the log data.

Hope it helps somebody…

 

You may also interested in

Unable to resolve superclass of Activity

Unable to resolve superclass

When you added Android Support library to your project in Eclipse ADT, to implement classes like FragmentActivity, ViewPager etc At times you may see this error which results in app crash due to Unable to resolve superclass,

Unable to resolve superclass of Lin/AppPath/MainActivity; (9)
05-16 14:10:11.705: W/dalvikvm(6534): Link of class 'Lin/AppPath/MainActivity;' failed
05-16 14:10:11.705: D/AndroidRuntime(6534): Shutting down VM
05-16 14:10:11.705: W/dalvikvm(6534): threadid=1: thread exiting with uncaught exception (group=0x41ba5c08)
05-16 14:10:11.705: E/AndroidRuntime(6534): FATAL EXCEPTION: main
05-16 14:10:11.705: E/AndroidRuntime(6534): Process: , PID: 6534
05-16 14:10:11.705: E/AndroidRuntime(6534): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{/.MainActivity}: java.lang.ClassNotFoundException: Didn't find class ".MainActivity" on path: DexPathList[[zip file
......
....

There may be a chance that Android Private Library, not exported while generating API file. Due to Android Private Libraries is unchecked in Order and Export tab in Java build path dialog as shown below. resolve superclass So, just check the Android Private Libraries and Click Ok. Clean and Build the app. Fixes the issue.

private_Library1

Hope it helps somebody. 🙂

You may be also interested in

ScrollView auto scroll to show content in app screen

While displaying long text data or displaying data in lot of views, we use ScrollView to view whole screen by scrolling. At times we may require app to auto Scroll down in a screen to show a bottom content.

If you try using below code in Activity’s OnCreate method to scroll down in ScrollView

ScrollView mScrollView = (ScrollView) findViewById(R.id.myScrollView);
mScrollView.fullScroll(ScrollView.FOCUS_DOWN);

It won’t scroll. Since the layout is not yet done adding all views and you call fullScroll immediately after instantiating the ScrollView.

Solution for ScrollView to auto scroll down

auto scroll

To solve this issue, A short delay gives, the system enough time to settle. You have to use following code to set the delay

mScrollView.postDelayed(new Runnable() {
    @Override
    public void run() {
       //replace this line to scroll up or down
       mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
    }
}, 100L);

voila, you can see app Scroll down to bottom of screen.

Similarly, If you want to set Scroll to top of screen, in above run() method replace line with

mScrollView.scrollTo(0, 0);

If you are using HorizotalScrollView, and if you want to move to right end of screen, use following code..

mHorizontalScrollView.postDelayed(new Runnable() {
    @Override
    public void run() {
      mHorizontalScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
    }
}, 100L);

here mHorizontalScrollView is object of HorizantalScrollView.

Hope it helps somebody.

🙂

You may be also interested in

Display AlertDialog with Multiple Options

AlertDialog with Multiple Options

Hi Guys, At times you may require to show multiple options in a dialog on Acitivty. So user can select any one option. here is the simple code to display with AlertDialog with Multiple Options

CharSequence options[] = new CharSequence[] {"Call", "SMS", "Email"};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle("Select your option:");
builder.setItems(options, new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
      // the user clicked on options[which]
   }
});
builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
      //the user clicked on Cancel
   }
});
builder.show();

You can see as shown below

AlertDialog

Cheers …:)

You may be also interested in

Logcat Clearing too Fast- Eclipse

While running app on latest android devices, from ADT Eclipse, you may find difficulty in viewing LogCat data. As lots of other background services of different apps are running, logcat clearing out in a glimpse.

At this kind of situation, To view LogCat data you have to change a Eclipse setting as shown below..

Goto Window ->Preferences -> In left panel expand Android -> select LogCat -> here in right panel you can see Maximum number of LogCat messages to buffer set as 5000,

Change this value to some large number like 500000. Click Apply and then Ok. (You may get a Error notifying a preference change listener. just ignore it.)

logcat clearing

Now you can able to see LogCat data.

Hope it helps somebody.

Cheers 🙂

 

You may be also interested in