• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Problem retrieving GPS location

I have an app with 3 activities. MainActivity is the initial screen that is shown to the user. SecondActivity is an activity that allows a user to scan a QR code. After the code is scanned, ThirdActivity is started.

That ThirdActivity shows the GPS location so that I can use it later in the app.

To deal with the location, I have created this helper class:

public class LocationHelper {
private static GeoLocation mLocation;

private static LocationRequest mLocationRequest;

private static long UPDATE_INTERVAL = 10 * 1000; /* 10 secs */
private static long FASTEST_INTERVAL = 2000; /* 2 sec */

public static void start(Context context)
{
startLocationUpdates(context);
getLastLocation(context);
}

@SuppressLint("MissingPermission")
protected static void startLocationUpdates(Context context) {

// Create the location request to start receiving updates
mLocationRequest = new LocationRequest();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(UPDATE_INTERVAL);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);

// Create LocationSettingsRequest object using location request
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
builder.addLocationRequest(mLocationRequest);
LocationSettingsRequest locationSettingsRequest = builder.build();

// Check whether location settings are satisfied
// https://developers.google.com/android/reference/com/google/android/gms/location/SettingsClient
SettingsClient settingsClient = LocationServices.getSettingsClient(context);
settingsClient.checkLocationSettings(locationSettingsRequest);

// new Google API SDK v11 uses getFusedLocationProviderClient(this)
getFusedLocationProviderClient(context).requestLocationUpdates(mLocationRequest, new LocationCallback() {
@override
public void onLocationResult(LocationResult locationResult) {
// do work here
onLocationChanged(locationResult.getLastLocation());
}
},
Looper.myLooper());
}

public static GeoLocation getLocation() {
return mLocation == null ? new GeoLocation() : mLocation;
}

protected static void onLocationChanged(Location location) {
if (mLocation == null)
mLocation = new GeoLocation();

mLocation.setLatitud(location.getLatitude());
mLocation.setLongitud(location.getLongitude());
}

@SuppressLint("MissingPermission")
protected static void getLastLocation(Context context) {
// Get last known recent location using new Google Play Services SDK (v11+)
FusedLocationProviderClient locationClient = getFusedLocationProviderClient(context);

locationClient.getLastLocation()
.addOnSuccessListener(location -> {
// GPS location can be null if GPS is switched off
if (location != null) {
onLocationChanged(location);
}
})
.addOnFailureListener(e -> {
Log.d("LocationHelper", "Error trying to get last GPS location");
e.printStackTrace();
});
}
}

In MainActivity onCreate method I am calling `LocationHelper.start(this);` so that location starts to be getting.

In ThirdActivity onCreate method I cam calling `GeoLocation location = LocationHelper.getLocation();`.

The problem is that on some execution, `getLocation` retrieves the location correctly, but on other execution, `getLocation` sets longitude and latitude both to 0.

What is the problem with my code?

Unofficial client for Mailtrap

Unofficial%2Bclient%2Bfor%2BMailtrap-feature-graphic.png

IMPORTANT: This is a 3d party non-official plugin
Mailtrap is a Trademark of Railsware Products, Inc.

Unofficial client for Mailtrap is a simple application that helps you manage your inbox at Mailtrap.io

Unofficial client for Mailtrap is completely free, fully customizable and be updated based on users feedback

Advantages:
• No advertising
• Without asking for more access rights, your privacy is always respected.

Features:
• Manage multiple api key

Notes:
We always believe and hope in you and everyone.
So we always try to create better and free apps.

We also listen to you, please send us feedback at any time.
Fanpage: https://www.facebook.com/unofficial.client.for.mailtrap.io
Email: admin@hamatim.com

You can get it APK 1.0 from:
Google Drive: https://drive.google.com/file/d/1LxwT2-bjuAm7l7bRf7kYfciRrTM7O2Dc/view?usp=sharing
Amazon Appstore: https://www.amazon.com/gp/product/B08H5RZP3C
Huawei AppGallery: https://appgallery5.huawei.com/#/app/C102825043

Or from thread/blog:
Daynhauhoc: https://daynhauhoc.com/t/client-cho-mailtrap-io-v1-0/107645
XDA: https://forum.xda-developers.com/android/apps-games/unofficial-client-mailtrap-t4157599
AndroidForum: https://androidforums.com/threads/unofficial-client-for-mailtrap.1327896/
Blog: https://03794577.blogspot.com/2020/09/unofficial-client-for-mailtrap.html

Attachments

how to fix android.process.acore has stopped working

When i try to dial out i get this message android process acore has stopped working pls try again. Could someone tell me how i could fix this error and what could i have done for this to have happenned?
Much Appreciated.
farkyeah05!:D
It doesn't work for me. I have a Lenovo P1ma40 (Lenovo VIBE). Can you please tell me how to resolve this Error?
Android ver: 5.1
Hardware ver: H401
Thanks. :oops:

EDIT: Fixed by deleting the ERROR app... And REBOOTING!

Z-Flip doesn't connect to Dr.Fone/MobileTrans

I got the Z-Flip in March and at that time I was able to transfer WhatsApp, SMS, contacts etc. from my iPhone Xs to the Z-Flip, using Dr. Fone. I haven't used the Z-Flip since then because there was no belt holster available and I kept on using the iPhone. Meanwhile I was able to find a belt holster which arrived 2 weeks ago and so I decided to update the data on the Z-Flip. There was also an Android-update. However, since these updates, Dr. Fone doesn't connect to the Z-Flip anymore. It recognizes it but the bar gets stuck at approx 75%. The same thing happens when I use MobileTrans (which I think is the same program just different design).
Once or twice I read the note on the phone "connector app needs to be updated" but when I clicked on "update", nothing happened.
Does anyone had/have the same issue and -most important- a solution for the problem ?
Thank you

Fragment not displaying RecyclerView.

I'm trying to have 2 fragments on my screen, currently only one is showing up and its vertical instead of horizontal which I assume is because my second fragment isn't showing up.
The Fragment in question that isn't working is my MapFragment.

Firstly ill show the code where I commit the transactions.

```
public class MainActivity extends AppCompatActivity {

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

FragmentManager fragmentManager = getSupportFragmentManager();
MapFragment mapFrag = (MapFragment) fragmentManager.findFragmentById(R.id.map);
SelectorFragment selectorFrag = (SelectorFragment) fragmentManager.findFragmentById(R.id.selector);

if (mapFrag == null)
{
//Create the Fragment Object
mapFrag = new MapFragment();
//Queues the operation to attach a Fragment
//Tells it where to add and what to add.
//Commit makes it happen
fragmentManager.beginTransaction().add(R.id.map, mapFrag).commit();
}

if (selectorFrag == null)
{
//Create the Fragment Object
selectorFrag = new SelectorFragment();
//Queues the operation to attach a Fragment
//Tells it where to add and what to add.
//Commit makes it happen
fragmentManager.beginTransaction().add(R.id.selector, selectorFrag).commit();
}

}
}
```

So the Selector Fragment displays fine except for being Vertical.

Now ill post my main xml associated with the above Activity.

```
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".MainActivity">
<FrameLayout
android:id="@+id/map"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/selector"
/>

<FrameLayout
android:id="@+id/selector"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/map"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

```

So the Map should be constrained to the top and take up 3/4 of the screen.

Now Ill show the Map Fragment Code followed by the xml for the Map Fragment.

```
public class MapFragment extends Fragment {

//Private Classfields
private MapData map;
private MyAdapter adapter;

@override
public View onCreateView(LayoutInflater inflater, ViewGroup ui, Bundle bundle)
{
//Takes a layout reference, instantiates all View objects.
//Reads the XML and creates the UI Based on it.
//Returns the root View object.
View view = inflater.inflate(R.layout.fragment_map, ui, false);

//Setup any event handlers below.

//Setting up RecyclerView
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.mapRecyclerView);

//Specify how it should be laid out.
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), MapData.HEIGHT, GridLayoutManager.HORIZONTAL, false));

//Have your data ready.
map = MapData.getInstance();

//Create your adapter
adapter = new MyAdapter(map);

//Attach Adapter to Recycler View.
recyclerView.setAdapter(adapter);

return view;
}


//Nested ViewHolder inside Fragment
private class MyDataVHolder extends RecyclerView.ViewHolder
{
private ImageView topLeftImageView, topRightImageView, bottomLeftImageView, bottomRightImageView, mainImageView;

public MyDataVHolder(LayoutInflater li, ViewGroup parent)
{
super(li.inflate(R.layout.grid_cell, parent, false));
//Divide the RecyclerViews runtime height by the number of cells
//that must fit in that space(MapData.HEIGHT)
//Add 1 to account for rounding errors that might leave a 1 pixel gap.
//Size value becomes the width and the height of the grid cell.
int size = parent.getMeasuredHeight()/MapData.HEIGHT + 1;
ViewGroup.LayoutParams lp = itemView.getLayoutParams();
lp.width = size;
lp.height = size;
//Grab UI Elements
//textView = (TextView) itemView.findViewById(R.id.list_data);
topLeftImageView = (ImageView) itemView.findViewById(R.id.topLeftImageView);
topRightImageView = (ImageView) itemView.findViewById(R.id.topRightImageView);
bottomLeftImageView = (ImageView) itemView.findViewById(R.id.bottomLeftImageView);
bottomRightImageView = (ImageView) itemView.findViewById(R.id.bottomRightImageView);
mainImageView = (ImageView) itemView.findViewById(R.id.mainImageView);

}

public void bind(MapElement mapElement)
{
//Set the image views.
//ImageView iv = ...;
//MapElement me = ...;
//iv.setImageResource(me.getNorthWest());
if (mapElement == null)
{
System.out.println("Map Element is null.");
}
else
{
System.out.println("Map Element is not null.");
}
topLeftImageView.setImageResource(mapElement.getNorthWest());
topRightImageView.setImageResource(mapElement.getNorthEast());
bottomLeftImageView.setImageResource(mapElement.getSouthWest());
bottomRightImageView.setImageResource(mapElement.getSouthEast());
if (mapElement.getStructure() != null)
{
mainImageView.setImageResource(mapElement.getStructure().getDrawableId());
}
}
}

private class MyAdapter extends RecyclerView.Adapter<MyDataVHolder>
{
private MapData map;

public MyAdapter(MapData inMap)
{
map = inMap;
}

@NonNull
@override
public MyDataVHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater li = LayoutInflater.from(getActivity()); //Fragment Method

return new MyDataVHolder(li, parent);
}

@override
public void onBindViewHolder(@NonNull MyDataVHolder holder, int position) {
int row = position % MapData.HEIGHT;
int column = position / MapData.HEIGHT;

MapElement currentMapElement = map.get(row, column);
holder.bind(currentMapElement);
}

@override
public int getItemCount() {
return map.HEIGHT * map.WIDTH;
}
}

private void updateUI(int pos)
{
adapter.notifyItemChanged(pos);
}
}

```

No here is the Map XML containing a singular RecyclerView.

```
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mapRecyclerView"
/>
```

Here is the grid cell xml that the Fragment inflates.

```
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<ImageView
android:id="@+id/topLeftImageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@android:color/transparent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toLeftOf="@id/topRightImageView"
app:layout_constraintBottom_toTopOf="@id/bottomLeftImageView"
app:layout_constraintWidth_default="percent"
app:layout_constraintHeight_default="percent"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintHeight_percent="0.5"
/>

<ImageView
android:id="@+id/topRightImageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@android:color/transparent"
app:layout_constraintLeft_toRightOf="@id/topLeftImageView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@id/bottomRightImageView"
app:layout_constraintWidth_default="percent"
app:layout_constraintHeight_default="percent"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintHeight_percent="0.5"
/>

<ImageView
android:id="@+id/bottomLeftImageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@android:color/transparent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/topLeftImageView"
app:layout_constraintRight_toLeftOf="@id/bottomRightImageView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintWidth_default="percent"
app:layout_constraintHeight_default="percent"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintHeight_percent="0.5"
/>

<ImageView
android:id="@+id/bottomRightImageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@android:color/transparent"
app:layout_constraintLeft_toRightOf="@id/bottomLeftImageView"
app:layout_constraintTop_toBottomOf="@id/topRightImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintWidth_default="percent"
app:layout_constraintHeight_default="percent"
app:layout_constraintWidth_percent="0.5"
app:layout_constraintHeight_percent="0.5"
/>

<ImageView
android:id="@+id/mainImageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@android:color/transparent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

</androidx.constraintlayout.widget.ConstraintLayout>

```

Not sure why this isn't working and guessing it must be something fiddly that me and my peers are missing.

Cheers, if there is any other code you would like for context ill be hanging around.

Thanks for the help in advance.

Andriod not sending or receiving texts

Just switched from an Iphone to an Android (LG Q7 plus), and switched from FreedomPop (That uses the Sprint network) to Metro by Tmobile.

1. I am not able to send or recieve texts through any apps including:

Messaging
Android Messagers
Chomo SMS
FB messenger

I tried setting my default messaging app to each of these to no avail.

2. Also factory reset my phone. Still not working.

3. I have a Google Voice account so I've been using my GV number to send and recieve texts, but I want to do this through my default messaging app on my official cell phone number and I want to make sure I dont miss texts from people texting my cell phone number.

4. Also changed my APN network settings but still not working.

What else can I do? Anyone else have this problem? How did you fix it?

Very frustrating. Please help &#128528;

Thanks in advance!



I can't guarantee that this will fix your problem but it's something you can try. So go into Settings>About Phone and scroll down to where you see your Build Number and tap that box repeatedly (for my phone it was 15 taps) until it says that Developer Options enabled then go into the Developer Options and scroll down until you see Cellular Data Always Active and turn that option on then restart your phone and for me my problem was fixed!

Help Texts intermittently not sending

Ok my problem was very similar I wasn't able to send any messages half the time and if I was connected to Wi-Fi I couldn't send them at all and I spent days and weeks coming the internet trying to find a solution and was not able to. So hypothetically I may have done some things I shouldn't have and in the process I discovered the solution to MY PROBLEM, I can't guarantee that this will fix your problem but it's something you can try. So go into Settings>About Phone and scroll down to where you see your Build Number and tap that box repeatedly (for my phone it was 15 taps) until it says that Developer Options enabled then go into the Developer Options and scroll down until you see Cellular Data Always Active and turn that option on then restart your phone and for me my problem was fixed! I hope that this method will help some of y'all, if it works post back and let us know for future answer seekers.
This fix my problem, thanks a lot!!!!

browser for old android

Is there a working web browser for android 2.1 with endless support ? Im using a smartphone from 2014 and intend to use it forever. Of course motherf rs from the Google and Co dont like this kind of affairs when people use old equipment decades on (because if everyone started doing that they would not receive money from sales and would have to shut down the company or work for little profit, what obviously they don't like) they want you to buy a new one every year and old one to throw to garbage, to Africa. So under pretense of security they make web browser unfunctional on old systems, renewing java and all other sh t so you cannot log in into stupid mail, google drive or open any site, enter capcha, ect. What i found so far out of huge range of sh t offered today is puffin browser, which later version is supposed to work on 2.3. Is there, can anyone create a good working alternative that would be without stupid security but receive updates on Google tricks to make equipment unfunctional?

As has been mentioned above, security is a constant reaction game, and old hardware and software is risky; developers can't just say, "here's a minimalistic software, oh by the way, it's not one bit secure".

That being said, there are plenty of phones on Amazon and Aliexpress in the thirty to fifty dollar range, short on memory and processing, but plenty minimalistic.

Filter

Back
Top Bottom