For smart Primates & ROBOTS (oh and ALIENS ).

Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Saturday, January 07, 2017

Failed to parse the output of adb version

Failed to parse the output of adb version

If you are getting this below error message while compiling Android code:

"Failed to parse the output of 'adb version': standard output was: error output was:
ADB not responding. If you'd like to retry, then please manually kill "adb.exe" and click 'Restart'"


The solution of this error; it is the time to reinstall your Operating system and then install latest version of Android IDE.

Share:

Thursday, March 12, 2015

TORCH IN ANDROID



If Torch in your mobile is not existing then download this Android App and you will get torch in your android mobile.


DOWNLOAD TORCH IN ANDROID HERE
Share:

Wednesday, March 11, 2015

BAR AND QR CODE READER IN ANDROID

Bar and QR code reader/scanner in android
This android app will read Bar code and QR code. It is based on zxing, so after install it download zxing. it will automatically detect zxing in you mobile. if not found then ask you about to download automatically.



BAR AND QR CODE READER IN ANDROID
















Download it from here
BAR AND QR CODE READER IN ANDROID
Share:

Sunday, January 18, 2015

android.os.NetworkOnMainThreadException

Problem:

The runtime this error 
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AnroidBlockGuardPolicy.onNetwork(StrictMode.java
is the common error when working with online activity work in android.
how to remove it?

Solution:

You need to put below lines to solve this:
StrictMode.ThreadPolicy thpolicy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(thpolicy);

Example:

Use below code after setContentView(..);

setContentView(R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy thpolicy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(thpolicy);
}

And also use below code before  onCreate(..)

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {...}
Share:

unable to start activity ComponentInfo MainActivity java.lang.NullPointer Exception

Problem:

While working with Android you can face the error
Fatal Exception:java.lang.RuntimeException:unable to start activity ComponentInfo
MainActivity : java.lang.NullPointer Exception
So how to overcome this run time error in android?

Solution:

This type of error is occurs when you trying to access android control Button or
EditText before set main activity. so first set you activity and then after it access the control

Example:

Do not use as belowloginBtn = (Button)findViewById(R.id.button1);
u_login = (EditText)findViewById(R.id.editText1);
setContentView(R.layout.activity_main);

Use as belowsetContentView(R.layout.activity_main);
loginBtn = (Button)findViewById(R.id.button1);
u_login = (EditText)findViewById(R.id.editText1);








Share:

Thursday, December 25, 2014

change SurfaceView height width

Problem:

change SurfaceView height width in android.
You are using SurfaceView to open camera in Android. and want to set it's custom height and width. So How can you change SurfaceView height width?

Solution:

To change SurfaceView's custom height and width use "android.view.ViewGroup.LayoutParams"
There are subclasses of LayoutParams for different subclasses of ViewGroup. For example, AbsoluteLayout has its own subclass of LayoutParams which adds an X and Y value.  By this you can change X and Y of SurfaceView 

Example:

Use below  code:
android.view.ViewGroup.LayoutParams avvglp = surfaceView.getLayoutParams();
avvglp.height=300;
avvglp .width=300;
surfaceView.setLayoutParams(avvglp);

To See more here:
http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html
Share:

Friday, September 26, 2014

android.os.NetworkOnMainThreadException


android.os.NetworkOnMainThreadException


if you work with android and want to get data from any url by using URL and  URLConnection you me stuck by the "android.os.NetworkOnMainThreadException" error message while run the app.

To over come this run time error message you use "StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();  StrictMode.setThreadPolicy(policy);" as listed below.

Keep in mind that use it in onCreate(Bundle savedInstanceState) after "setContentView(R.layout.activity_main);" method

//////////////////////////////////////////
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//// other code here
}
//////////////////////////////////////////

Share:

Saturday, October 05, 2013

Animation in android

Animation in android

Animation animation = new TranslateAnimation(0, 500,0, 0);
        animation.setDuration(1000);
        Button pan_card_tracker = (Button) findViewById(R.id.pan_card_
tracker);
        pan_card_tracker.startAnimation(animation);
Share:

Friday, August 30, 2013

Blink Text in Android

Blink Text in Android




1) create a folder in res named "anim"
under this create a blink.xml file as listed below:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@

android:anim/accelerate_interpolator"
        android:duration="600"
        android:repeatMode="reverse"
        android:repeatCount="infinite"/>
</set>





in MainActivity

private Animation animBlink;
protected void onCreate(...) {
 textView1 = (TextView) findViewById(R.id.textView1);
 animBlink = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
 animBlink.setAnimationListener(this);
 textView1.startAnimation(animBlink);
}




Share:

Change text background color in android

Change text background color in android

static Handler h;
protected void onCreate() {
this.h = new Handler() {
    public void handleMessage(Message msg) {
        switch (msg.what) {
                case 0:
        Random rnd = new Random();
            int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
            txtMessage.setBackgroundColor(
color);
                break;
               }
               super.handleMessage(msg);
           }};
    ChangeBGColor u =new ChangeBGColor("", "");
        new Thread(u).start();
}

in other class

import android.os.Message;
public class ChangeBGColor implements Runnable {
 public ChangeBGColor(String inputFileName,String surl) {
 }
 @Override
 public void run() {
  boolean ans=false;
  int cc=0;
  while(ans!=true) {
    try {
    Thread.sleep(2000);
    Message message= new Message();
    cc++;
    message.obj = " "+cc;
    cc--;
    MainActivity.h.sendMessage(message);
    } catch(Exception ee) { }
  }
}
}
Share:

Rotate any text in android


Rotate any text in android

////// Rotate any text ///////////////////////////
static int flag=0;
private Handler mHandler;
final Context context=this;
RelativeLayout.LayoutParams par;
private int mCount = 0;
protected void onCreate() {
mHandler = new Handler();
mHandler.post(mCountUpdater);


}
private Runnable mCountUpdater = new Runnable() {
// private int mCount = 0;
@Override
public void run() {
rotate();
flag++;
mCount++;
if(mCount>=360) {
mCount=0;
}
mHandler.postDelayed(this, 1);
}
};
public void rotate() {
txtMessage.setRotation(


mCount);

}
Share:

Ads Inside Post

Powered by Blogger.

Archive