Thursday, 15 October 2015

How to change tooltip background color in Ubuntu

Install and open gnome-color-chooser Install gnome-color-chooser.

Go to Specific → Tooltips and put black foreground over pale yellow background.

you are done !!

Flurry in Android

Flurry is used as analytic tool for android. Flurry is supported and provided by Yahoo.

How to use flurry in an application?

It's actually really simple.
1 - Head to flurry.com and register for your app, which will generate a unique tracking code.
2 - Download and add the FlurryAgent jar to your project libraries. If you're using Eclipse, right-click your project folder, select properties, select Java Build Path, and choose Add External JARs...
3 - Add android.permission.INTERNET to your AndroidManifest.xml.
4 - Add a call to the Flurry agent from the onStart() and onStop methods of your activities.
Note: replace the ID below with your unique tracking code.
public void onStart()
{
   super.onStart();
   FlurryAgent.onStartSession(this, "9GKQD4EBX123FEP6874H");
   // your code
}

public void onStop()
{
   super.onStop();
   FlurryAgent.onEndSession(this);
   // your code
}

Thursday, 9 July 2015

How to remove all breakpoints at a time in Android Studio

ctrl + shift + f8

How to auto import the necessary classes in Android Studio with shortcut


For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:
  • change Insert imports on paste value to All
  • markAdd unambigious imports on the fly option as checked

Saturday, 27 June 2015

How to add Google Play Services to Android Studio



  1. Go to File -> Project Structure
  2. Select 'Project Settings'
  3. Select 'Dependencies' Tab
  4. Click '+' and select '1.Library Dependencies'
  5. Search for : com.google.android.gms:play-services
  6. Select the latest version and click 'OK'

Integrating facebook in android studio (Method - 2)

Start your New Android Project

1. Create a new project in Android Studio from File ⇒ New ⇒ Android Application Project .
2. Now minimize or close your Android Studio. Go to your project directory inside it create a new folder.
3. UnZip your facebook SDK folder, now we need to copy facebook project files to our newly created libraries folder. Open your unzip folder and find facebook folder. In my case i found here F:\socialsdk\facebook-android-sdk-3.16.0\facebook-android-sdk-3.16 i extract facebook sdk in f drive inside socialssdk. You find your where you extract sdk files.
Copy this facebook folder to your libraries folder.
 4. Now open your copied facebook folder inside libraries and we need to remove some folder which we don’t need in our project and remove other file and folders.
5. Now open your android studio and open your project you create for this. Now find your libraries folder in your project and facebook inside.
5.  Open your facebook build.gradle inside facebook folder we need to configure 
Libraries ⇒ facebook ⇒ build.gradle
i.e.
android {
compileSdkVersion 21 buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 16 targetSdkVersion 21 versionCode 1 versionName "1.0" }
You also copy and paste above code in your build.gradle.
6. Now open your ProjectDirectory ⇒ settings.gradle. In this file we need to include our facebook library.
include ':libraries:facebook'

 7. Now you need to configure your project structure shortcut Ctrl+Alts+Shift+S .

After click on button select Module ⇒ Dependencies ⇒ ⇒ Module Dependencies 
After this select facebook module and click ok button and then Apply  and let grable sync after this your Facebook SDK is ready to  use in your project.

Monday, 22 June 2015

How To Add A Library Project to Android Studio


1. Go to File -> New -> Import Module.
2. Source Directory -> Browse the project path.
3. Let Android Studio build the project.

Wednesday, 13 May 2015

How to add project as library in Android Studio


  1. Open your project in Android Studio.
  2. Go to File > Import Module and import the library as a module.
  3. Go to File > Project Structure > Modules.
  4. Locate your main project module, click on it. It should have a few android libraries such as support-v4 etc.
  5. Go to Dependency tab Click on the more on the green "+" button > Module dependency.
  6. Select imported Module.

Tuesday, 28 April 2015

Set Text Color for textView Android

You can use
  textView1.setTextColor(getResources().getColor(R.color.mycolor))
or
  textview1.setBackgroundColor(Color.parseColor("#ffffff"));
or
 textview1.setBackgroundColor(Color.RED);
or
 textView1.setBackgroundColor(R.color.black);

Sunday, 26 April 2015

Getting Started with Android Studio

mipmap Folders in android studio


It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.




What is the short cut to Auto import all in Android Studio?

For Windows/Linux, you can go to File -> Settings -> Editor -> Auto Import -> Java and make the following changes:
  • change Insert imports on paste value to All
  • markAdd unambigious imports on the fly option as checked


Android Studio short cuts 

Go to class CTRL + N
Go to file CTRL + Shift + N
Navigate open tabs ALT + Left-Arrow; ALT + Right-Arrow
Look up recent files CTRL + E
Go to line CTRL + G
Navigate to last edit location CTRL + SHIFT + BACKSPACE
Go to declaration CTRL + B
Go to implementation CTRL + ALT + B
Go to source F4
Go to super Class CTRL + U
Show Call hierarchy CTRL + ALT + H
Search in path/project CTRL + SHIFT + F
Programming Shortcuts:-
Reformat code CTRL + ALT + L
Optimize imports CTRL + ALT + O
Code Completion CTRL + SPACE
Issue quick fix ALT + ENTER
Surround code block CTRL + ALT + T
Rename and Refractor Shift + F6
Line Comment or Uncomment CTRL + /
Block Comment or Uncomment CTRL + SHIFT + /
Go to previous/next method ALT + UP/DOWN
Show parameters for method CTRL + P
Quick documentation lookup CTRL + Q
Delete a line CTRL + Y
View declaration in layout CTRL + B


Thursday, 23 April 2015

How to remove red exclamation mark on eclipse project


  1. Right click on the "Project name"
  2. Select "Build path"
  3. Then select "Configure Build Path"
  4. Click on "Libraries"
  5. Remove all the libraries which were referring to old path
  Then, the exclamation symbol on the "Project name" was removed.

Tuesday, 14 April 2015

How to use Custom Toast in Android

Custom Toast

// *********** Creating Custom Toast ***********

            public void CustomToast(String msg) {
                       
                        ViewGroup parent = (ViewGroup) findViewById(R.id.container);
                       
                        LayoutInflater inflater = getLayoutInflater();
                       
                        View customToastroot = inflater.inflate(R.layout.toast, parent , false);

                        Toast customtoast = new Toast(BookNow.this);
                       
                        TextView tv_tost = (TextView)customToastroot.findViewById(R.id.tv_tost);
                       
                        tv_tost.setText(msg);
                        customtoast.setView(customToastroot);
                   customtoast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0);
                        customtoast.setDuration(Toast.LENGTH_LONG);

                        customtoast.show();
            }

you just have to call the method CustomToast() where ever you need .

Saturday, 11 April 2015

Storing Values in Android


Intent


How to use putExtra() and getExtra()


Use this to "put" the file...

Intent i = new Intent(FirstScreen.this, SecondScreen.class);
i.putExtra("name", "value");

Then, to retrieve the value try ...

Bundle b = getIntent().getExtras();
if(b!=null){
String j = b.getString("name");
}

Example :-

first Screen.java
text=(TextView)findViewById(R.id.tv1);
edit=(EditText)findViewById(R.id.edit);
button=(Button)findViewById(R.id.bt1);
button.setOnClickListener(new OnClickListener() {
    public void onClick(View arg0) {
        String s=edit.getText().toString();
        Intent i=new Intent(MainActivity.this, newclass.class);
        i.putExtra("name", s);
        startActivity(i);
    }
});

Second Screen.java
public class newclass extends Activity
{
    private TextView Textv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.intent);
        Textv = (TextView)findViewById(R.id.tv2);
        Bundle b = getIntent().getExtras();
        if(b!=null)
        {
            String j =(String) b.get("name");
        }
    }

}


Shared Preferences


Use this to "put" the file...

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
Editor editor = prefs.edit();
editor.putString(PREF_NAME, "");
editor.commit();

Then, to retrieve the value try ...

SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(YouActivity.this);

String servername = settings.getString("sharedPreferencesKey", "defaultValue");
server.setText(servername);

Friday, 10 April 2015

Problems you might face with in Eclipse

Eclipse won't show files in package explorer

You just need to click 'File' -> 'Import' -> 'General' -> 'Existing Projects into Workspace' and select the missing projects in the window that appeared.

Thursday, 9 April 2015

On default Android Back Button Customiztion

 How To Override the “Back” button so it doesn't Finish() my  Activity?



public void onBackPressed() {
   Intent setIntent = new Intent(Intent.ACTION_MAIN);
   setIntent.addCategory(Intent.CATEGORY_HOME);
   setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   startActivity(setIntent);
}

Android Back Button to specific activity

public void onBackPressed() {

  super.onBackPressed();

  startActivity(new Intent(ThisActivity.this, NextActivity.class)); 

  finish();

  }

How to disable back button in android

@Override
public void onBackPressed() {
    // do nothing.
}