I'm trying to implement a simple follow me application for an android device (oneplus 6t) using the DJI SDK and a Phantom 3 pro. This is the code I've come up with so far and the method is called when I click a button but all I get is the first toast message and the drone doesn't follow. Then when I toggle off the button to stop the follow me mission it says that this command is not supported in this flight mode. Can anyone please help me understand what is wrong?

 private FollowMeMissionOperator getFollowMeOperator() {
    return DJISDKManager.getInstance().getMissionControl().getFollowMeMissionOperator();
}
   private void followMeStart() {
    // Creates object with last known GPS coordinates of tablet/phone
    @SuppressLint("MissingPermission") Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    //check if status of aircraft is ready to execute
    if (getFollowMeOperator().getCurrentState().toString().equals(FollowMeMissionState.READY_TO_EXECUTE.toString())) {
        //Toast.makeText(getApplicationContext(), "Ready to execute", Toast.LENGTH_SHORT).show();

        //if ready to execute, create new mission that points aircraft in direction of object using the latitude, longitude and height of the drone.
        float height = (float) KeyManager.getInstance().getValue(FlightControllerKey.create(FlightControllerKey.ALTITUDE));
        double latitude = (double) KeyManager.getInstance().getValue(FlightControllerKey.create(FlightControllerKey.AIRCRAFT_LOCATION_LATITUDE));
        double longitude = (double) KeyManager.getInstance().getValue(FlightControllerKey.create(FlightControllerKey.AIRCRAFT_LOCATION_LONGITUDE));
        FollowMeMission missionOne = new FollowMeMission(FollowMeHeading.TOWARD_FOLLOW_POSITION, latitude, longitude, height);

        Toast.makeText(getApplicationContext(), "Altitude: " + height + "\nLatitude: " + latitude + "\nLongitude: " + longitude , Toast.LENGTH_SHORT).show();

        //starts the new mission just created
        getFollowMeOperator().startMission(missionOne, new CommonCallbacks.CompletionCallback() {
            @Override
            public void onResult(DJIError djiError) {

                if (djiError == null) {
                    Toast.makeText(getApplicationContext(), "Ready and mission Started", Toast.LENGTH_SHORT).show();

                    Thread locationUpdateThread = new Thread(new Runnable() {
                        @Override
                        public void run() {

                            while (getFollowMeOperator().getCurrentState().toString().equals(FollowMeMissionState.EXECUTING.toString())) {
                                //create object to get location
                                @SuppressLint("MissingPermission") Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                                getFollowMeOperator().updateFollowingTarget(new LocationCoordinate2D(location.getLatitude(), location.getLongitude()), new CommonCallbacks.CompletionCallback() {
                                    @Override
                                    public void onResult(DJIError djiError) {
                                        if (djiError != null) {
                                            Toast.makeText(getApplicationContext(), "Failed to update target GPS", Toast.LENGTH_SHORT).show();
                                        }
                                    }
                                });
                                try {
                                    Thread.sleep(1000);
                                } catch (InterruptedException e) {
                                    // The exception clears the interrupt flag so I'll refresh the flag otherwise the thread keeps running
                                    Thread.currentThread().interrupt();
                                }
                            }
                        }
                    });
                    locationUpdateThread.start();
                }else{
                    Toast.makeText(getApplicationContext(), "Ready but stuck at on result", Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        Toast.makeText(getApplicationContext(), "Not ready to execute", Toast.LENGTH_SHORT).show();
    }
}

I created an Android app (with Android Studio) run in the emulator that makes requests to API REST php (executed locally with Xammp). This API represents the interface layer to the mysql database (local) and perform classic CRUD operations with appropriate security checks. Everything works well locally.

My question is:

Assuming to publish the app on the Android store, how can I bring the REST php API (with mysql database) on a public hosting? Which providers would you recommend?

Of course I did a test by publishing the files on a classic web hosting with attached db and it all works ...

but... is this the correct way?

can it go well if the demand load increases? I accept advice

Thank you.

I want to make an app for tracking my spendings. I have a database with a table called categories. In this table, I save the category_id(int), category_name(varchar), limit_week(int), limit_month(int). If I don't want to have limits, they can be null. Adding categories works perfectly.

Now I want to display the Categories in a RecyclerView. The Layout for the items looks like that:

<androidx.cardview.widget.CardView android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardBackgroundColor="@color/card_color"
app:contentPadding="@dimen/card_content_padding"
app:cardElevation="@dimen/card_elevation"
android:layout_margin="@dimen/card_margin">

<androidx.constraintlayout.widget.ConstraintLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tvCat"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tvLimWeek"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/weekly_limit"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tvCat" />

    <TextView
        android:id="@+id/tvLimMonth"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/monthly_limit"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tvLimWeek" />

    <TextView
        android:id="@+id/tvLimWeekEnter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toEndOf="@id/tvLimMonth"
        app:layout_constraintTop_toTopOf="@id/tvLimWeek"
        android:layout_marginLeft="@dimen/margin_16sp"
        android:layout_marginStart="@dimen/margin_16sp" />
    <TextView
        android:id="@+id/tvLimMonthEnter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toEndOf="@id/tvLimMonth"
        app:layout_constraintTop_toTopOf="@id/tvLimMonth"
        android:layout_marginLeft="@dimen/margin_16sp"
        android:layout_marginStart="@dimen/margin_16sp" />

    <ProgressBar
        android:id="@+id/progressBarWeek"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/tvLimWeekEnter"
        app:layout_constraintTop_toTopOf="@+id/tvLimWeekEnter"
        android:max="100"/>

    <ProgressBar
        android:id="@+id/progressBarMonth"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/tvLimMonthEnter"
        app:layout_constraintTop_toTopOf="@+id/tvLimMonth"
        android:max="100"/>

</androidx.constraintlayout.widget.ConstraintLayout>

I only want to show the progress bars, when there is a limit, otherwise I want to remove them. This is my adapter for the RecyclerView:

class CategoryAdapter(private val mCats: List<Category>, private val context: Context): RecyclerView.Adapter<CategoryViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryViewHolder {
    return CategoryViewHolder(LayoutInflater.from(context).inflate(R.layout.categories_view, parent, false))
}

override fun getItemCount() = mCats.size

override fun onBindViewHolder(holder: CategoryViewHolder, position: Int) {
    val cat: Category = mCats[position]
    holder.tvCat.text = cat.cat_name
    if(cat.limit_week != null)
        holder.tvLimitWeekEnter.text = cat.limit_week.toString()
    else {
        holder.tvLimitWeek.height = 0
        holder.tvLimitWeekEnter.height = 0
    }
    if(cat.limit_month != null)
        holder.tvLimitMonthEnter.text = cat.limit_month.toString()
    else {
        holder.tvLimitMonth.height = 0
        holder.tvLimitMonthEnter.height = 0
    }
}

}

I don't know if I can somehow remove the TextViews, soI just set the height to 0. But now I need to remove the progress bars, where I can't change the height. So is there a way to remove them?

I have a simple CalculatorActivity with consecutively shown Fragments :

  1. InputFragment //requests two input values for calclation
  2. ResultFragment // show the result of the calculation

To keep it simple lets assume, I want to calculate the sum of two numbers. I start the CalculatorActivity which immediately loads the InputFragment via:

fun replaceFragment(resId : Int, newFragment : Fragment){
    this.supportFragmentManager?.beginTransaction()?.replace(resId, newFragment)?.addToBackStack(null)?.commit()
}

resId is the resource ID for the container to inflate the fragment in. newFragment is the new Fragment to be inflated. Here in this first step I call in CalculatorActivity's onCreate():

replaceFragment(R.id.container, InputFragment.getInstance())

SO FAR this works fine.

But when I enter the required numbers in InputFragment, how can I forward the values from InputFragment back to the calling CalculatorActivity, so that it can continue and inflate the ResultFragment into the very same container to show the result of calculation?

So I'm pretty sure that I'm kind of at a loss here.

The expected behavior is:

Get data from API -> save it in the local DB -> load data from the local DB and display it

First of all in my Fragment I call a function that does this:

mLiveData = viewModel.fetchAllCategories(getString(R.string.lang_code))
mCategoryLiveData!!.observe(this, Observer<Array<Category>> { it ->
            if (it != null) {
                this@CategoryListFragment.allCategories = SparseArray(it.size)
                for (category in it) {
                        allCategories[category.id] = category
                }   

                displayedCategory = allCategories[1]
                this@CategoryListFragment.mLoadingCircle.visibility = View.GONE
                this@CategoryListFragment.displayCategoryChildren()
            }
        })

fetchAllCategories calls a function in the ViewModel which calls this function:

fun getAllCategoriesFromAPI(language: String): Flowable<Array<Category>> {
    return service.getAllCategories(language)
        .doOnNext {
        Log.e("Repository", "Fetched ${it.size} Categories from the API ")                
        storeCategoriesInDb(it)
    }
}

However the function displayCategoryChildren() fires before the onNext finishes which results in an error since the data the app is supposed to get from the db is not saved there yet.

If it is in any way relevant I can also post the fuction in the ViewModel

I have an app where users can switch between a list fragment and a map fragment using a switch within the single activity. I am having issues where when a users switches the fragment view, onCreateOptionsMenu.

This has become an issues as I have a spinner in the actionbar that allows users to filter data to a filter of there choice and it is being reset if a user decides to switch view.

IE. filtering by "English Earthquakes" on the list view shows the desired result but switching to the map view resets because the map fragment calls onCreateOptionsMenu again.

showing the ability to switch fragment dynamically

onCreateOptionsMenu method in MainActivity

    //Inflating Menue
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.toolbar_menu,menu);


    MenuItem item = menu.findItem(R.id.spinner);
    spinner = (Spinner) item.getActionView();

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.action_share,  getResources().getStringArray(R.array.Planets)){
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            //Explicitly used to turn spinner into an icon
            LayoutInflater inflater=getLayoutInflater();
            View view=inflater.inflate(R.layout.action_share, parent, false);

            return view;
        }
    };

    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter);
    spinner.setBackground(getResources().getDrawable(android.R.drawable.ic_menu_search));

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
    {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
        {
            String selectedItem = parent.getItemAtPosition(position).toString();
            ChangeView(selectedItem);
        } // to close the onItemSelected
        public void onNothingSelected(AdapterView<?> parent)
        {

        }
    });

    return true;

Fragment switching code within onCreate in MainActivity

        onOffSwitch = (Switch)  findViewById(R.id.switchy);
    onOffSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if(isChecked == true){
                //Changes to the map Fragment
                ft = getSupportFragmentManager().beginTransaction();
                ft.replace(R.id.framlayoutMap, new NonListfragment());
                ft.addToBackStack(null);
                ft.commit();
            }
            else
            {
                //Changes to the list fragment
                ft = getSupportFragmentManager().beginTransaction();
                ft.replace(R.id.framlayoutMap, new EQListFragment ());
                ft.addToBackStack(null);
                ft.commit();
            }
        }
    });

    //Used to set it so the starting of the application does not have blank fragment
    ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.framlayoutMap, new EQListFragment ());
    ft.commit();

onCreate in List Fragment

public class EQListFragment extends ListFragment implements AdapterView.OnItemClickListener {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    setHasOptionsMenu(false);
}

onCreate in the map fragment does not have sethasOptionsMenu set to false as it extends FragmentActivity

The matter is how to stop a fragment calling onCreateOptionsMenu in the parent activity when its loaded. It seems this also happens when the device is roated.

I would like to add a Repeat Button (onClick) to my Media player. I have the play, pause and stop buttons like in code below. how can i add the Repeat Button for make the music is playing in Media player to be repeated like a loop by a Repeat button clicked from the user. This is my Media Player Code:

public class Musica extends AppCompatActivity implements Runnable {
private Button pause;
private Button stop;
private SeekBar mseek;
private MediaPlayer mp;
private Thread soundThread;
private Button play;

//list
AdRequest adRequest;
private AdView adView;

ListView listm;

String[] itemname = {
        "music 1",
        "music 2",
        "music 3",
        "music 4",
        "music 5",
        "music 6",
        "Lullaby 1",
        "Lullaby 2",
        "Lullaby 3",
        "Lullaby 4",
        "Lullaby 5",

};


Integer[] imgid = {
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,
        R.drawable.musicon,

};


@Override
protected void onDestroy() {
    super.onDestroy();
    if (mp != null) {
        mp.stop();
        mp.release();
        mp = null;
    }
}


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_musica);

    getSupportActionBar().hide();



    adView = (AdView)findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .build();
    adView.loadAd(adRequest);

    adView.setAdListener(new AdListener() {

        @Override
        public void onAdLoaded() {
            adView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAdFailedToLoad(int error) {
            adView.setVisibility(View.GONE);
        }

    });


    CustomListAdapterMusic adapter = new CustomListAdapterMusic(this, itemname, imgid);
    listm = (ListView) findViewById(R.id.listmusic);
    listm.setAdapter(adapter);

    listm.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {

            // TODO Auto-generated method stub

            String Slecteditem = itemname[+position];
            Toast.makeText(getApplicationContext(), Slecteditem, Toast.LENGTH_SHORT).show();


            if (position == 0) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.babyone);
                mp.start();
            }


            if (position == 1) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.babytwo);
                mp.start();
            }


            if (position == 2) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.water);
                mp.start();
            }


            if (position == 3) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.ocean);
                mp.start();
            }


            if (position == 4) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.rain);
                mp.start();
            }


            if (position == 5) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.sm);
                mp.start();
            }
            if (position == 6) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.classica);
                mp.start();
            }


            if (position == 7) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.relax6);
                mp.start();
            }

            if (position == 8) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.twinkle7);
                mp.start();
            }

            if (position == 9) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.ninar11);
                mp.start();
            }

            if (position == 10) {

                stopPlaying();

                mp = MediaPlayer.create(Musica.this.getBaseContext(), R.raw.lullaby9);
                mp.start();
            }



            play = (Button) findViewById(R.id.bplay);
            pause = (Button) findViewById(R.id.bpause);
            stop = (Button) findViewById(R.id.bstop);
            mseek = (SeekBar) findViewById(R.id.seekBar);


            setupListeners();
            soundThread = new Thread(Musica.this);
            soundThread.start();


        }


    });


}

private void stopPlaying() {
    if (mp != null) {
        mp.stop();
        mp.release();
        mp = null;
    }
}


private void setupListeners()

{


    play.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mp.start();

        }
    });


    pause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mp.pause();

        }
    });


    stop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View currentView) {
            mp.stop();

        }
    });


    mseek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                mp.seekTo(progress);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });


}


@Override
public void run() {
    int currentPosition = 0;
    int soundTotal = mp.getDuration();
    mseek.setMax(soundTotal);


    while (mp != null && currentPosition < soundTotal) {

        try {
            Thread.sleep(300);
            currentPosition = mp.getCurrentPosition();
        } catch (InterruptedException SoundException) {
            return;

        } catch (Exception otherException) {
            return;

        }
        mseek.setProgress(currentPosition);


    }


}

}

I'm using DownloadManager to download files.

But I have multiple files that "belong" together as one item, so I'd like to have a "queue" for those, and display the notification in a way that it shows the progress of the "queue" (let's say I added 5 files to the queue, so it would show 20% after the 1st file is downloaded, 40% after 2 of them,... or get the total filesize as max value for the progress file, and increase the progress bar according the already downloaded files sizes)

currently, I already downloading the files with, but the downloadmanager show me the progress for each file separately instead of 1 entry showing the progress for the whole queue together.

Mutiple files as multiple downloads, it should be one notification with the total progress.

How can I show a notification with the total download progress instead of seperate downloads?

This question is related to: How to download multiple files with android DownloadManager so that it appears in one queue

This question already has an answer here:

I have set all of the required permission in proper manner in manifest file but i don't what i am doing wrong.

manifest.xml

Errors I get:

1-"Missing permissions required by InterstitialAd.loadAd: android.permission.INTERNET"
2-"Missing permissions required by MobileAds.initialize: android.permission.INTERNET" 3-"Missing permissions required by BaseAdView.loadAd: android.permission.INTERNET"

and i get frustrated about this error i don't know how to resolve. i have followed all of the solution like invalid cache restart,clean rebuild,set permission etc.. but it didn't worked at all please can someone help me out.

MainActivity.java:

public class AnswerPaper extends Activity {

    private View.OnClickListener buttonClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.but5:
                    Intent mIntent1 = new Intent(AnswerPaper.this, bscitactivity.class);
                    mIntent1.putExtra("file_name", "answers");
                    startActivity(mIntent1);
                    break;
                case R.id.but6:
                    Intent mIntent2 = new Intent(AnswerPaper.this, bscactivity.class);
                   mIntent2.putExtra("file_name", "answers");
                   startActivity(mIntent2);
                    break;
                case R.id.but7:
                      Intent mIntent3 = new Intent(AnswerPaper.this, bscbiotech.class);
                   mIntent3.putExtra("file_name", "answers");
                   startActivity(mIntent3);
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.questionspapers);
        defineButtons();




        Button b = (Button) findViewById(R.id.but6);
        Button b2 = (Button) findViewById(R.id.but7);


        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(AnswerPaper.this,pop.class));
            }
        });



        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(AnswerPaper.this,pop.class));
            }

        });


    }

    public void defineButtons() {
        findViewById(R.id.but5).setOnClickListener(buttonClickListener);
        findViewById(R.id.but6).setOnClickListener(buttonClickListener);
        findViewById(R.id.but7).setOnClickListener(buttonClickListener);


        MobileAds.initialize(this,"ca-app-pub-2775391703689141/2346081028");
        AdView adView = (AdView)findViewById(R.id.banner_AdView);
        AdRequest adRequest = new AdRequest.Builder()

                .build();
        adView.loadAd(adRequest);


    }
}

I am having some trouble figuring out how to view a custom class in one of my activities. When I try to run it the app just crashes with the error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{g.companieshouse.companieshouse/g.companieshouse.companieshouse.GraphActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class g.companieshouse.companieshouse.DrawGraphTest

Below is my code:

The class that draws a canvas:

public class DrawGraphTest extends View {

int mWidth = this.getResources().getDisplayMetrics().widthPixels;
int mHeight = this.getResources().getDisplayMetrics().heightPixels;

    public DrawGraphTest(Context context) {
        super(context);
        //Various paints and such...

        //Set point to middle of screen
        point1 = new Point(mWidth / 2, mHeight / 2);
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        //Draw various stuff to canvas
}

The activity:

public class GraphActivity extends AppCompatActivity {
    DrawGraphTest drawGraphTest;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_graph);
        drawGraphTest = (DrawGraphTest)findViewById(R.id.drawGraphTest);

    }
}

XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".GraphActivity">

<g.companieshouse.companieshouse.DrawGraphTest
    android:id="@+id/drawGraphTest"
    android:layout_width="350dp"
    android:layout_height="300dp"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

I also wanted to ask if it is possible to scale what is drawn in "DrawGraphTest" class so that it fits within the bounds of the custom view on the activity? Currently it is set up to fit the entire screen of whatever device the app is being run on (see point1), Cheers!

I have 2 edittext in each list item, so onclick a item i am currently getting all the text at once displayed in a list item, but i want them seperately.

xml

<EditText
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="20dp"/>
<EditText
        android:id="@+id/roll"
        android:layout_width="wrap_content"
        android:layout_height="20dp"/>

onclick function

listviewQuestion.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String questionid = String.valueOf(parent.getItemAtPosition(position));
                Toast.makeText(QuestionListActivity.this, item, Toast.LENGTH_LONG).show();
            }
        });

current output

{name=abc,roll=123}

But i want to extract name and roll seperately.

preface: I'm building an application for a building that can navigate a user, one of the ways I am doing this is by using a floor plan of the building and I want to draw a path between nodes in this floor plan to create a route (not with realtime updates). The user enters where they want to be and after my route finding algorithm has outputted a path I want to use that for my line placement.

I have used a library called Photo View to allow me to zoom in and move the image of the floor plan around the screen but I need to draw my route on, and then have it follow the floor plan as if it was part of the image. Realistically I think for the drawing I'd want the canvas size to be relative to the image not the screen (so 0,0 is the top-left corner of the image) but I'm unsure on how to access this.

Am I going down the wrong path using Photo View and should I be using something native to dart/flutter instead?

I also want to add a FAB that I can press to draw my route over the original image but I don't know how to go around this with the child issue

Here's some of what I have so far:

Widget build(BuildContext context) {
  return Container(
    child: new CustomPaint(
    foregroundPainter: RoutePainter(),
    child: PhotoView(
      imageProvider: AssetImage('assets/images/floor1_temp.png'),
      minScale: PhotoViewComputedScale.contained,
    maxScale: 1.5,
    ),
  ));
}

Created a drawable with rounded corners on the top left and right. Applying it to the layout for a BottomSheetDialogFragment.

It's applying correctly but where the corners are, behind them is white instead of transparent. How would I fix this?

Image showing the issue:

enter image description here

Here's the drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="?backgroundColor" />
    <corners
        android:topLeftRadius="16dp"
        android:topRightRadius="16dp" />
</shape>

And here's the layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bg_bottom_dialog"
    android:orientation="vertical"
    android:paddingStart="16dp"
    android:paddingTop="8dp"
    android:paddingEnd="16dp"
    android:paddingBottom="8dp">

    <Button
        android:id="@+id/joinNowButton"
        style="?attr/primaryButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_gravity="center_horizontal"
        android:layout_margin="8dp"
        android:background="?attr/buttonPrimaryColor"
        android:text="@string/iap_sell_join_now"
        android:textColor="?attr/textColorButtonPrimary"
        android:visibility="visible" />

    <TextView
        android:id="@+id/welcomeUserText"
        android:layout_width="wrap_content"
        android:layout_height="56dp"
        android:background="@android:color/transparent"
        android:gravity="center"
        android:textColor="?attr/textColorPrimary"
        android:textSize="16sp"
        android:visibility="gone"
        tools:text="Welcome Member" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:background="?attr/textColorAccent" />

    <TextView
        android:id="@+id/settingsText"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@android:color/transparent"
        android:drawableStart="@drawable/ic_settings_white"
        android:drawablePadding="32dp"
        android:drawableTint="?textColorPrimary"
        android:gravity="start|center_vertical"
        android:text="@string/nav_settings"
        android:textColor="?textColorPrimary"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/faqText"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@android:color/transparent"
        android:drawableStart="@drawable/ic_close"
        android:drawablePadding="32dp"
        android:drawableTint="?textColorPrimary"
        android:gravity="start|center_vertical"
        android:text="@string/nav_faq"
        android:textColor="?textColorPrimary"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/contactText"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@android:color/transparent"
        android:drawableStart="@drawable/ic_close"
        android:drawablePadding="32dp"
        android:drawableTint="?textColorPrimary"
        android:gravity="start|center_vertical"
        android:text="@string/nav_contact_us"
        android:textColor="?textColorPrimary"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/signOutText"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@android:color/transparent"
        android:drawableStart="@drawable/ic_close"
        android:drawablePadding="32dp"
        android:drawableTint="?textColorPrimary"
        android:gravity="start|center_vertical"
        android:text="@string/nav_sign_out"
        android:textColor="?textColorPrimary"
        android:textSize="16sp" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="8dp"
        android:background="?attr/textColorAccent" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="48dp">

        <TextView
            android:id="@+id/privacyPolicyText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toStartOf="@id/bottom_sheet_dot"
            android:background="@android:color/transparent"
            android:padding="8dp"
            android:text="@string/nav_privacy"
            android:textColor="?textColorPrimary"
            android:textSize="16sp" />

        <View
            android:id="@+id/bottom_sheet_dot"
            android:layout_width="2dp"
            android:layout_height="2dp"
            android:layout_centerInParent="true"
            android:layout_marginStart="16dp"
            android:layout_marginEnd="16dp"
            android:background="?attr/textColorPrimary" />

        <TextView
            android:id="@+id/termsText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toEndOf="@id/bottom_sheet_dot"
            android:background="@android:color/transparent"
            android:gravity="start|center_vertical"
            android:padding="8dp"
            android:text="@string/nav_terms"
            android:textColor="?textColorPrimary"
            android:textSize="16sp" />
    </RelativeLayout>

</LinearLayout>

Since I upgraded my monitor to 4k, I have a problem with the Android emulator. On my system (KDE neon 5.15) the AVD does not scale the display of the device, but only the device itself, as it can be seen here: Display of Android device not scaled. So it's almost impossible for me to click on the right area on the display, as the input field of the touch gestures is also scaled correctly, but only the display itself is not. I already checked similiar problems on stack overflow like 4k display & Android emulator: fail, but non of them seem to have the same problem. Does any one else have experienced a similiar problem on Linux and 4k monitors?

I'm learning React Native (without React knowledge), but my problem is the status bar always get a translucent black background and I can remove it. I tried every stackoverflow answer, and even React Native and Expo documentation. But nothing...

Here is my problem: enter image description here

The status bar has a white background supposedly, and get this grey overlay, that is what I want to remove.

Here is my code:

render() {
    return (
         <View>
             <StatusBar background="white" />
             <Button title="Sign in!" onPress={this._signInAsync} />
         </View>
    );
}

I even tried this, on app.js

"androidStatusBar": {
    "backgroundColor": "#C2185B"
},

I'm starting to think, this is related to Expo.

I want to set the text view into the time the user selected from the alert dialog box. After the user selects it, they press the ok button, and I need to set the time selected from the dialog box, to the list view in main activity. Or maybe there would be a way to somehow import the text view from the custom xml list view, into the main activity and set the text.

In short what I need to do is set the Text view from a different xml List view, to the time chosen by the user in the dialog box.

This is my code:

public class MainActivity extends AppCompatActivity {


    private static final String TAG = "MainActivity";
    private TaskHelper mHelper;
    private ListView mTaskListView;
    private ArrayAdapter<String> mAdapter;
    Dialog dialog;
    Calendar currentTime;
    int hour, minute;
    String format;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ImageView imgSettings = findViewById(R.id.imgSettings);
        mHelper = new TaskHelper(this);
        mTaskListView = findViewById(R.id.list_todo);
        ImageView bttnAddTodo = findViewById(R.id.bttnAddTodo);

        currentTime = Calendar.getInstance();
        hour = currentTime.get(Calendar.HOUR_OF_DAY);
        minute = currentTime.get(Calendar.MINUTE);

        updateUI();

        selectedTimeFormat(hour);


        bttnAddTodo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog();
            }
        });


        TextView tvDate = findViewById(R.id.tvDate);

        imgSettings.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
                startActivity(intent);
            }
        });

        String date = new SimpleDateFormat("E MMM dd, h:mm a", Locale.getDefault()).format(new Date());
        tvDate.setText(date);
    }

    public void selectedTimeFormat(int hour){
        if (hour == 0) {
            hour += 12;
            format = "AM";
        }

        else if(hour == 12){
            format = "AM";
        }

        else if(hour > 12){
            hour =-12;
            format = "PM";
        }

        else {
            format = "AM";
        }
    }

    public void AlertDialog(){

        dialog = new Dialog(MainActivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.custom_dialog);
        dialog.setTitle("Add Task");


        View item_todo = LayoutInflater.from(getApplication()).inflate(R.layout.item_todo, null);


        final TextView tvTimeReminder = item_todo.findViewById(R.id.tvTimeReminder);

        Window window = dialog.getWindow();
        assert window != null;

        ImageView ivCheckmark = dialog.findViewById(R.id.ivCheckmark);
        final ImageView ivMintIdle = findViewById(R.id.imgMintIdle);
        final TextView tvHmmAdd = findViewById(R.id.tvHmmAddSomething);
        final EditText etTask = dialog.findViewById(R.id.etTask);
        final TextView tvPickTime = dialog.findViewById(R.id.tvPickTime);
        ImageView ivTime = dialog.findViewById(R.id.ivTime);

        ivCheckmark.setEnabled(true);
        etTask.setEnabled(true);
        tvPickTime.setEnabled(true);
        ivTime.setEnabled(true);

        ivTime.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TimePickerDialog timePickerDialog = new TimePickerDialog(MainActivity.this, TimePickerDialog.THEME_DEVICE_DEFAULT_DARK, new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        selectedTimeFormat(hourOfDay);
                        tvPickTime.setText(hourOfDay + " : " + minute + " " + format);
                    }
                },  hour, minute, true);
                timePickerDialog.show();

            }
        });

        ivCheckmark.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(etTask.getText().toString().trim().isEmpty()){
                    Toast.makeText(MainActivity.this, "Please enter a task first.", Toast.LENGTH_SHORT).show();
                }
                else {
                    ivMintIdle.setVisibility(View.GONE);
                    tvHmmAdd.setVisibility(View.GONE);
                    String task = String.valueOf(etTask.getText());
                    SQLiteDatabase db = mHelper.getWritableDatabase();
                    ContentValues values = new ContentValues();
                    values.put(Task.TaskEntry.COL_TASK_TITLE, task);
                    db.insertWithOnConflict(Task.TaskEntry.TABLE, null, values, SQLiteDatabase.CONFLICT_REPLACE);
                    tvTimeReminder.setText("yeet");
                    db.close();
                    updateUI();
                    etTask.setText("");
                    dialog.dismiss();
                }
            }

        });



        dialog.show();
        window.setGravity(Gravity.CENTER_HORIZONTAL);
        window.setLayout(1050, 1050);

    }
    public void bttnDelete(View view){
        View parent = (View) view.getParent();
        TextView taskTextView = parent.findViewById(R.id.tvTaskTitle);
        ImageView ivMintIdle = findViewById(R.id.imgMintIdle);
        TextView tvHmmAdd = findViewById(R.id.tvHmmAddSomething);
        String task = String.valueOf(taskTextView.getText());
        SQLiteDatabase db = mHelper.getWritableDatabase();
        db.delete(Task.TaskEntry.TABLE, Task.TaskEntry.COL_TASK_TITLE + " = ?", new String[] {task});
        db.close();
        updateUI();


        if (mAdapter.isEmpty()){
            ivMintIdle.setVisibility(View.VISIBLE);
            tvHmmAdd.setVisibility(View.VISIBLE);
        }


    }

    private void updateUI() {
        ArrayList<String> taskList = new ArrayList<>();
        SQLiteDatabase db = mHelper.getReadableDatabase();
        Cursor cursor = db.query(Task.TaskEntry.TABLE,
                new String[] {Task.TaskEntry.COL_TASK_TITLE}, null, null, null, null, null);

        while (cursor.moveToNext()) {
            int index = cursor.getColumnIndex(Task.TaskEntry.COL_TASK_TITLE);
            taskList.add(cursor.getString(index));
        }

        if (mAdapter == null) {
            mAdapter = new ArrayAdapter<String>(this, R.layout.item_todo, R.id.tvTaskTitle, taskList);
            mTaskListView.setAdapter(mAdapter);

        } else {
            mAdapter.clear();
            mAdapter.addAll(taskList);
            mAdapter.notifyDataSetChanged();
        }

        cursor.close();
        db.close();
    }

}

This is the db i use to save my Task title and the item:

        public class Task {

        public static final String  DB_NAME = "com.saikauskas.julius.todolist2.db";
        public static final int DB_VERSION = 1;

        public class TaskEntry implements BaseColumns{
            public static final String TABLE = "tasks";
            public static final String COL_TASK_TITLE = "title";
            public static final String COL_TASK_TIME = "time";
        }

    }

And this is my xml for the item_todo(the custom list view):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TodoLinearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tvTaskTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start|right"
        android:layout_marginTop="15dp"
        android:fontFamily="@font/open_sans"
        android:text="Task Here"
        android:textColor="@color/colorAccent"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/tvTimeReminder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start|right"
        android:layout_marginTop="1dp"
        android:fontFamily="@font/ubuntu"
        android:text="15:58pm"
        android:textColor="@color/colorAccent"
        android:textSize="17sp"
        android:visibility="visible" />

    <Button
        android:id="@+id/bttnDeleteTask"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:onClick="bttnDelete"
        android:text="DELETE" />

</LinearLayout>

I just need to add a menu screen but I’m not sure how you would do that.

Im very new in java, and have been trying this for days now, seems that i need to profundize the bases way more, anyway, it seems that i cant get the toast right, here's the code.

public class MainActivity extends AppCompatActivity {
    EditText web;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = findViewById(R.id.button);
       final EditText web = findViewById(R.id.web);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String webastring = web.getText().toString();
                Toast.makeText((this,web.toString(), "asd", Toast.LENGTH_SHORT).show();
            }
        });

    }
}

I implemented face recognition with Vision Framework.
The model is trained with turicreate.

https://github.com/apple/turicreate

But the accuracy is not good.
I am using 200 face images of same person to train the model with turicreate to identify him on the camera view.
But for all faces, the confidence is over 90%.

Do you have any tips for me?
Thanks

So I recently found through this question that I can make UIViews in ARKit. So that's what I'm trying to do.

And so far I've got it woking, as to display the rendered SCNPlane and even have animations run on it. However, I can't seem to trigger any of my recognisers or even the touchesDidBegan(...).

Also I've added my recognisers on a subview of my contentVC's view don't know if that's important... Did any of you experience sth like this or can confirm that touches normally work If you put a UIView on a SCNPlane ?

Cuz my idea was to somehow cast a ray and do a hit test and convert everything to the correct points and then trigger some recognizedTouch() in MyVC.. any better ideas?

AR Setup code in init():

contentVC = MyVC()
let vcPlane = SCNPlane()
vcPlane.materials.first?.diffuse.contents = contentVC.view
let vcNode = SCNNode(geometry: vcPlane)
sceneView.scene.rootNode.addChildNode(vcNode)

in MyVC.viewDidLoad():

let newView = UIView(frame: CGRect(...)            
let rec = UITapGestureRecognizer(target: self, action: #selector(MyVC.myRecognizerFunction))
newView.addGestureRecognizer(rec)