I have created a toggle button programmatically and using it but when it is running on device ,the status of toggle button is overlapping over the toggle button.like in the image enter image description here

the code for toggle is given below

  ToggleButton tb[];
            tb=new ToggleButton[len];
            tb[i]=new ToggleButton(this);

            LinearLayout.LayoutParams tbparams = new LinearLayout.LayoutParams
                    (90, LinearLayout.LayoutParams.WRAP_CONTENT);
            tbparams.setMargins(20, 0, 0, 0);
            tb[i].setTextOff(" ");
            tb[i].setTextOn(" ");
            tb[i].setPadding(4, 4, 4, 4);

            tb[i], tb[i].getId(),tb[i].getTag(),stringList));


<?xml version="1.0" encoding="UTF-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!--<item android:drawable="@drawable/on" android:state_checked="true"/>

    <item android:drawable="@drawable/off" android:state_checked="false"/>
    <item android:drawable="@drawable/off"></item>-->

    <item android:drawable="@drawable/onsw" android:state_checked="true"/>

    <item android:drawable="@drawable/offsw" android:state_checked="false"/>
    <item android:drawable="@drawable/offsw"></item>


please help

I have an Activity with viewpager in one page should be EditText and other page be the TextView, get data from first fragment to show in second view but I'm struggling because of lack of knowledge, I have Main Activity as

public class MainActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        viewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));

    private class MyPagerAdapter extends FragmentPagerAdapter {

        public MyPagerAdapter(FragmentManager fm) {

        public Fragment getItem(int pos) {
            switch(pos) {

                case 0: return EditFragment.newInstance("FirstFragment, Instance 1");
                case 1: {
                    Log.e("TAG", " is " + new EditFragment().getTag());
                    return PreviewFragment.newInstance(new EditFragment().getTag());

                default: return EditFragment.newInstance("ThirdFragment, Default");

        public int getCount() {
            return 2;

main layout is

 <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"

EditFragment is

public class EditFragment extends Fragment {

    public EditFragment(){}

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_editor, container, false);

        EditText tv = (EditText) v.findViewById(R.id.content);

        return v;

    public static EditFragment newInstance(String text) {

        EditFragment f = new EditFragment();
        Bundle b = new Bundle();
        b.putString("msg", text);


        return f;


public class PreviewFragment extends Fragment {

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_markdown, container, false);

        TextView tvView = (TextView) v.findViewById(R.id.markdownView);

        return v;

    public static PreviewFragment newInstance(String text) {

        PreviewFragment f = new PreviewFragment();
        Bundle b = new Bundle();
        b.putString("msg", text);


        return f;

there I do not know how to pass data from EditFragment to PreviewFragment, please help.

I'm newbie to Fragments please help me.

At shell level I use:

adb shell getprop 

to get properties If I have to get property information at application level which command am I supposed to use. I tried

String productname = System.getProperty("ro.product.name")

and getting no error but It is not returning correct value what could be the reason.

I have some icons in a grid view . when the icons are selected it will be replaced with tick mark. But when the grid view is scrolled , the icon is in the orinal form(not changed). So please help me to find a solution.!!

enter code here

 public View getView(int position, View convertView, ViewGroup parent) {
 View v;
 View myview=convertView;

  if (myview == null) {

      imageView = new ImageView(mContext);

      imageView = (ImageView) convertView;


    imageView.setLayoutParams(new GridView.LayoutParams(130, 130));
    imageView.setPadding(1, 1, 1, 1);

    Log.d("new", "newFrg0");
    try {
        String icon_name_val = null, icon_link_val = null, icon_flag_val = null;
        DatabaseHandler db = new DatabaseHandler(mContext);

        List<HomeIconset> icondetails = db.geticondetails();
        for (HomeIconset sp : icondetails) {
            icon_name_val = sp.getIcon_name();
            icon_link_val = sp.getIcon_link();
            icon_flag_val = sp.getIcon_flag();
            Log.d("new", "newFrg1");

            if (icon_name_val.equals(null)) {
                Log.d("new", "newFrg2");
            } else {
                Log.d("hhhh", icon_name_val + " " + icon_link_val + " " + icon_flag_val);
                int iconPosition = getPosition(icon_name_val);

                ArrayList<String> listOfSomething1 = new ArrayList<String>();

                for (int i = 0; i < listOfSomething1.size(); i++) {
                    Log.d("arraylist", listOfSomething1.get(i));

                Log.d("str", String.valueOf(iconPosition) + " " + String.valueOf(position));

                if (listOfSomething1.contains(String.valueOf(position))) {
                    Log.d("contains", String.valueOf(position));

                } else {


    } catch (Exception e) {
        Log.d("excep", e.getMessage().toString());
    return imageView;

I am trying to solve this problem for 4 hours and I am completely without hope.

I am using android studio for coding this application. I have created a simple activity which holds edit field for user name and password and next there is a button which is meant to be to submit data from these two edit fields.

I am using mysql connector/j and the java code is following:

package allanko.quizzerappandroid;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import java.sql.*;

public class LoginActivity extends AppCompatActivity
    private static CDatabase db;

    protected void onCreate( Bundle savedInstanceState )
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_login );

        db = new CDatabase();

    public static CDatabase getDB()
      return db;

    public class CDatabase
        private String db_name;
        private String db_user;
        private String db_pass;
        private Connection connection;
        private boolean isConnected;

        public CDatabase()
            db_name = "jdbc:mysql://localhost:3306/quizzer?useSSL=false";
            db_user = "quizzer";
            db_pass = "pass";
            connection = null;

            if( connect() == true )
              isConnected = true;
              isConnected = false;

        private boolean connect()
              connection = DriverManager.getConnection( db_name, db_user, db_pass );
              return true;
            catch( Exception exc )
              exc . printStackTrace();
              return false;

      private void printResult()
          TextView dbText = (TextView)findViewById( R.id.dbText );

          if( ! isConnected )
            dbText . setText( "Connection to database failed" );
            dbText . setText( "Connected to database." );

      public ResultSet query( String query) throws SQLException
          Statement statement = connection . createStatement();
          return statement . executeQuery( query );

      public boolean isConnected()
          return isConnected;

When I start this application on whether emulator or my phone, it every time write "Connection to database failed." and I am getting this from console:

W/art: Common causes for lock verification issues are non-optimized dex code
W/art: and incorrect proguard optimizations.
W/art: Class android.support.v4.util.LruCache failed lock verification and will run slower.
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
W/System.err: java.sql.SQLException: java.lang.VerifyError: Verifier rejected class com.mysql.jdbc.CharsetMapping: void com.mysql.jdbc.CharsetMapping.<clinit>() failed to verify: void com.mysql.jdbc.CharsetMapping.<clinit>(): [0x4287] Invalid reg type for array index (Precise Reference: com.mysql.jdbc.MysqlCharset[]) (declaration of 'com.mysql.jdbc.CharsetMapping' appears in /data/app/allanko.quizzerappandroid-1/base.apk)
W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:873)
W/System.err:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:422)
W/System.err:     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
W/System.err:     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
W/System.err:     at java.sql.DriverManager.getConnection(DriverManager.java:569)
W/System.err:     at java.sql.DriverManager.getConnection(DriverManager.java:219)
W/System.err:     at allanko.quizzerappandroid.LoginActivity$CDatabase.connect(LoginActivity.java:55)
W/System.err:     at allanko.quizzerappandroid.LoginActivity$CDatabase.<init>(LoginActivity.java:43)
W/System.err:     at allanko.quizzerappandroid.LoginActivity.onCreate(LoginActivity.java:19)
W/System.err:     at android.app.Activity.performCreate(Activity.java:6664)
W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
W/System.err:     at android.app.ActivityThread.-wrap12(ActivityThread.java)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err:     at android.os.Looper.loop(Looper.java:154)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6077)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
W/System.err: Caused by: java.lang.VerifyError: Verifier rejected class com.mysql.jdbc.CharsetMapping: void com.mysql.jdbc.CharsetMapping.<clinit>() failed to verify: void com.mysql.jdbc.CharsetMapping.<clinit>(): [0x4287] Invalid reg type for array index (Precise Reference: com.mysql.jdbc.MysqlCharset[]) (declaration of 'com.mysql.jdbc.CharsetMapping' appears in /data/app/allanko.quizzerappandroid-1/base.apk)
W/System.err:     at com.mysql.jdbc.CharsetMapping.getNumberOfCharsetsConfigured(CharsetMapping.java:687)
W/System.err:     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:464)
W/System.err:     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
W/System.err:     at java.lang.reflect.Constructor.newInstance0(Native Method)
W/System.err:     at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
W/System.err:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
W/System.err:   ... 19 more
W/gralloc_ranchu: Gralloc pipe failed

I am completely desperate because I tried to google everything that came to my mind and nothing worked.

Thanks in advance for your answers.

I'm using a Expandble RecyclerView, to display "projects" as parents and as childs the "issues".

I send the projects to the view, and it works perfect. I Shows, the projects, and when I do the Clikc on Projects , the project expands, showing the issues. But when I click on the Childs, i HAve to send this info to a new activity... and here is where the problem arrives..

The id's are taken the views get messed. With an example will be better:

I Expand both projects. I click on second child : SOP2016-57548 enter image description here

Then Activity with the child info launch, but don't launch the correct one: enter image description here

I can see because the description don't match with the json: enter image description here

And I don't know why is messig the views...

Here is the View Holder's:

Project Holder:

package jira.viewHolder;

import android.annotation.SuppressLint;
import android.os.Build;
import android.view.View;
import android.view.animation.RotateAnimation;
import android.widget.TextView;

import com.bignerdranch.expandablerecyclerview.ViewHolder.ParentViewHolder;

import es.in2.otr.app.im.R;
import jira.model.Project;

 * Created by eliasor on 13/05/2016.
public class ProjectViewHolder extends ParentViewHolder {

    private static final float INITIAL_POSITION = 0.0f;
    private static final float ROTATED_POSITION = 180f;

    //private final ImageView mExpandImageView;
    private TextView mProjectTextView;

     * Default constructor.
     * @param itemView The {@link View} being hosted in this ViewHolder
    public ProjectViewHolder(View itemView) {
        mProjectTextView = (TextView) itemView.findViewById(R.id.jir_project_name);
        //mExpandImageView = (ImageView) itemView.findViewById(R.id.btn_expand_toggle);

    public void bind(Project project) {

    public void setExpanded(boolean expanded) {

            RotateAnimation rotateAnimation;
            if (expanded) {//rotate clockwise
                rotateAnimation = new RotateAnimation(ROTATED_POSITION, INITIAL_POSITION,
                        RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                        RotateAnimation.RELATIVE_TO_SELF, 0.5f);
            } else { //rotate counterclockwise
                rotateAnimation = new RotateAnimation(-1 * ROTATED_POSITION, INITIAL_POSITION,
                        RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                        RotateAnimation.RELATIVE_TO_SELF, 0.5f);


    public void onExpansionToggled(boolean expanded) {

Issue Holder (Child):

package jira.viewHolder;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.bignerdranch.expandablerecyclerview.ViewHolder.ChildViewHolder;

import es.in2.otr.app.im.R;
import jira.activity.JiraIssueInput;
import jira.activity.JiraProjects;
import jira.adapter.ProjectAdapter;
import jira.model.Issue;

 * Created by eliasor on 13/05/2016.
public class IssueViewHolder extends ChildViewHolder{

    private TextView mIssueTextView; // contendra de momento el "summary" del issue
    private Context appContext;
    private static Issue mIssue;

    public IssueViewHolder(View itemView, final Context appContext) {
        this.appContext = appContext;
        this.mIssueTextView = (TextView) itemView.findViewById(R.id.jir_issue_name);
        this.mIssueTextView.setOnClickListener(new View.OnClickListener(){

            public void onClick(View v) {
                Log.d("JIRA", "CLICk CHILD");
                Log.d("JIRA", "CHILD NUM:"+getAdapterPosition() +"\nINFO CHILD: "+mIssue.toString());
                Toast.makeText(appContext, "CHILD #"+getAdapterPosition(), Toast.LENGTH_LONG).show();
                Intent intent = new Intent(appContext, JiraIssueInput.class);
                intent.putExtra("issue", mIssue);


    public void bind(Issue issue){
        this.mIssue = issue;

How can I fix it? thanks

I need a thread repeating after 30 seconds that load data from web service. i want to stop and start thread onResume and onPause so that it runs when screen is active and disable it when activity paused. Restart on resume.

new Handler().postDelayed(new Runnable() {

        public void run() {

    }, 30000);

How to stop it when activity paused.

I am using retrofit 2.0.0-beta1 and okhttp2.4.0 for get the response from server in android studio.I go the java.net.SocketTimeoutException when using api url with port number like http:\test.com:3000\getcustomers.Plesae help me to solve this problem.

API Url: http://test.com:3000/hotelbooking/userLogin. when using port no with api its not working in retrofit

I've looked around but never found a straightforward answer to this question. I'm wondering what would happen if I use a pattern that requires me to pass a Context to static methods to do things on the backend. For instance:

public static Observable<CreateThing> createNewThing(String thingName, Context context) { // Passing Context in
    return RestNetworker.handleResponse(ServiceGenerator.createService(Service.class).createThing(thingName))
            .doOnNext(response -> DatabaseHelper.getInstance(context).createThing(new Thing(response.getThingId(), thingName))); // context used to get instance of DatabaseHelper

This method makes an API call and then writes the object to the database locally after a success response. However, I need to pass a Context to create the instance of the database helper. I could alternatively pass the database helper itself, but then I'd be creating the instance (rather getting it, since it's singleton) in the Activity code and I'd rather not do that either.

My question really is: If, say, a user exits the Activity while the API call is in progress, will this Context instance get GC'd and result in an NPE when the response comes back? I've done this kind of thing before and never noticed that issue, but it really seems that there should be some consequence of doing this. I know that other developers must do some things off the UI thread that require a Context, so this should be a relatively easy question to answer.

Thanks guys! Please let me know if you need any more information to provide better context. Heh.

I have a listview with a heade view added to it. In this listview I have a fast scrollbar with section indexer. But the fast scrollbar start a the top of the list right to the header.

I would like fast scrollbar start at first item below header. Is it possible?

I have Vertical Bar chart with each bar of different color. Here Each series contains One item . Such list of Series are added to XYMultipleSeriesRenderer. I am not able to Reduce Bar spacing.

 private List<XYSeriesRenderer> getXYSeriesRenderer(){
        ArrayList<XYSeriesRenderer> xySeriesRenderers = new ArrayList<>();
        Resources resources = mActivity.getResources();
        XYSeriesRenderer xySeriesRenderer;

    for(int i = 0; i<5; i++){

        xySeriesRenderer = new XYSeriesRenderer();

        switch (i){
            case 0 :{

            case 1 : {

            case 2 : {

            case 3 : {

            case 4 : {

            default: {
        SDLog.d("Adding XYSeriesRenderer to List -> sySeriesRenderer :: "+ xySeriesRenderer.toString());

    return xySeriesRenderers;

then I do this:

for (XYSeries series: ratingSeries) {
            SDLog.d("Adding XY Series to Multiple Series Dataset :: title ->"+ series.getTitle());

Actually i have created custom keyboard for my application. It's working absolutely fine on every screen all the activities, but I don't know how to set custom keyboard on alert dialog.

I am using below code to call keyboard in activities:

    UserPayAmount.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {

            customFractionalKeyboard= new CustomFractionalKeyboard(VendorPaymentActivity.this, R.id.keyboard_number, R.xml.fractional_keyboard);


            return false;

I want to create keyboard on this dialog, above buttons.

So i'm making an application, and i'm using Maps API on Android and i have these two methods

public void onGpsStatusChanged(int i) {
    Log.i("gps status mudou",111+"");

So, the first one was implemented in API level 24 and the other one deprecated, since i want this application to work in almost all devices, what i want to know is if i have to use both methods or just one of them, and if is just one what should i use? Thank you

I have created a custom keyboard app , My app is consuming high RAM around 150-200 MB,when I tried to dump memory info from

adb shell dumpsys meminfo

this is what I get even when my keyboard is not opened.

                   Views:      364         ViewRootImpl:        1
             AppContexts:        3           Activities:        0
                  Assets:        5        AssetManagers:        5
           Local Binders:       45        Proxy Binders:       32
           Parcel memory:       16         Parcel count:       64
        Death Recipients:        4      OpenSSL Sockets:        0

Views:      364 //number increases when I open and close keyboard for few times.

How to clear these views?

I tried calling


it drops the memory consumption directly to 10 MB and clear all the views but in this case , my keyboard open very slowly.

Here is lifecyle,every time when I open keyboard (when I kill process on onFinishInputview) :

 I/FA: App measurement is starting up, version: 9256
 I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
 I/FirebaseInitProvider: FirebaseApp initialization successful
 I/MultiDex: install
 I/MultiDex: VM has multidex support, MultiDex support library is disabled.
 D/SoftKeyboard: onCreate invoked! 

 D/SoftKeyboard: onInitializeInterface invoked! 
 D/SoftKeyboard: onStartInput invoked!


Which uses the Android Widget Toolbar and takes the users GPS location, at Runtime after the Splash screen and before login Activity.

I know how to add permissions to the manifest and I am using both the permissions ACCESS_FINE_LOCATION and ACCESS_COURSE_LOCATION.

By using this command i am able to get the package. output:C:\Project\Tools\sdk-repo-windows-platform-tools-2219198\platform-tools>adb shell dumpsys window windows | grep -E 'mCurrentFocus' mCurrentFocus=Window{11dc5df u0 com.android.phone/com.android.phone.CallFeaturesSetting}

From this output i am getting package as com.android.phone, but i want to access the "callFeaturesSettings" using abd command for my automation. By using this command "adb shell monkey -p com.android.phone 1" i can access only the package but how to access the sub settings.

Please help!!

Hey having trouble with Swift 3. I have the following code:

public var urlSession : URLSession?
self.urlSession = URLSession(configuration: URLSessionConfiguration.default,
            delegate: self,
            delegateQueue: OperationQueue.main)

I am getting the following error message: "URLSession produces (), not the expected contextual result type URLSession?"

What am I doing wrong here?

Firstly refer to the graphic show below:

enter image description here

I have an NSArray that contains 9 Elements. Each of these 9 elements contain a further 5 Elements.

What I would like to do is take the [*][1] from each an place them into another which will only contain these dates.

How is this best achieved ??

How I can run Xcode 7.3.1 on a new mac OS Sierra? For now I always get crash on start.

enter image description here

We do have several Components in our product which are

  1. Component A
  2. Component B
  3. Component C

Dependencies are (if unmet the system fails):

A <-> B
B <-> C

We are currently creating a build pipeline and finally the Software for each component gets packaged into a single firmware image:

A -> Output A
B -> Output B
C -> Output C

Output A + Output B + Output C = Firmware

The firmware gets packed with some documentation and will then be deployed. Deployments should happen every week to testing and every 2-4 weeks to production.

Firmware + Docs = Deployed Software

My problem is now:

  • How do i ensure compatibility between A,B and C given the fact that they are all developed by different teams?

    I saw this question here Looking for best practice for version numbering of dependent software components

    We do have version numbers in place for A,B and C and the overall Firmware has one as well. Are there any best practices or ways to do it?

  • How do i track back compatibility? (Besides looking into the packaged firmware and see which versions got included at a certain point in time)

    I thought about using git tags here and put the Firmware Version number (only shipped products) as a tag on A,B,C.

I am tasked with redesigning an existing catalog processor and the requirement goes as below Requirement I have 5 to 10 vendors(each vendor can have multiple stores) who would provide me with 'XML' file per store. Basically, 1 products xml file per Store, and multiple Store files per Vendor. Max file size can be 500 MB and min can be 100 MB Avg products per file could be 100,000.

Sample xml format could be like this ... ... ...

It doesnt take more than 30 mins to download the file per store, and these files are updated once per day or every 3 to 6 hours.

Now priority requirement is that, the product details are highly unorganized and these files have to organized, processed(10+ processes) and converted to another common object(json) and then file stored in Cassandra.

My technology head advised me to design with Apache Flink and Kafka on top of HDFS, where flink directly stream the files from the vendor servers and start processing them while streaming.

My view was that, either case the files are of finite size and there is not much need to stream them. So thought of having a standalone scheduler come downloader to download and load the files to HDFS. As soon as the files are loaded to HDFS, I can trigger the Flink processing and store the same in Cassandra.

My question here is that, knowing the files are of finite size and finite counts irrespsective of the number of vendors, Is stream processing a overkill or a Batch processing would be a latency burden later?