Android MP3 track numbers erased

I’ve been having this strange problem on my Redmi Note 7 running MIUI 12.0.2.0 Global.

I’ve been using Shuttle and Musicolet players interchangeably because of their varying features and I have a lot of MP3 files stored in my SD card. The problem is that track numbers for tracks #8 and #9 on random folders keep getting erased.

I use Musicolet’s tag editor and correct the track numbers but after a few days, new tracks appear with the same problem.

Any ideas???

database – How to effectively sperate CRUD operations from the main SQLiteOpenHelper – android studio

I’m conflicting about how I want my database architecture to be built.
First of all, I use a singleton pattern for the database in order to insure one instance of it (so its thread-safe), and also for me to get a workable database reference wherever I have a context.

All across the application I make many different db operations, for example, some activities need to change only the ‘Meals’ table and some need to change ‘Meals’ & ‘MealFoods’ for example.

For each one of this tables I’ve built a helper class in order to separate the CRUD operations of each table apart from the DatabaseManager class (which extends SQLiteOpenHelper). This, of course is for the sake of simplicity and to get a cleaner code.

First approach:

This approach saves all the helper classes inside the DatabaseManager.

DatabaseManager.java:

public class DatabaseManager extends SQLiteOpenHelper {
    private static String dbName = "logs.db";
    private static final int dbVersion = 1;

    private final Context context;
    public MealsDBHelper mealsDBHelper;
    public MealFoodsDBHelper mealFoodsDBHelper;

    private DatabaseManager(@NonNull Context context) {
        super(context, dbName, null, dbVersio);
        this.context = context.getApplicationContext();//Saving as application context to avoid leaks
        mealsDBHelper = new MealsDBHelper(context);
        mealFoodsDBHelper = new MealFoodsDBHelper(context);
    }

    private static DatabaseManager instance;
    public static synchronized DatabaseManager getInstance(Context context) {
        if (instance == null) {
            instance = new DatabaseManager(context);
        }
        return instance;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //...
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //...
    }
}

Let’s look at the MealsDBHelper class, which pretty much all it does is to help communicate CRUD operations with the database. (For example a user wants to change his meal name)

public class MealsDBHelper {
    public static final String MEALS_TABLE_NAME = "Meals";
    public static final String MEAL_ID_COLUMN = "Meal_ID";
    public static final String MEAL_NAME_COLUMN = "Meal_Name";
    public static final String MEAL_POS_COLUMN = "Meal_Pos";
    public static final String MEAL_DATE_COLUMN = "Date";


    private Context context; //A context object to pass on to the DatabaseManager.getInstance method in all the different methods inside this class
    public MealsDBHelper(Context context){
        this.context = context;
    }

    //For example one of few methods that do operations on the 'Meals' table in the database.
    public void updateMealName(long mealId, String meal_name) {
        UserDataDB.getInstance(context).getWritableDatabase().execSQL("UPDATE " + MEALS_TABLE_NAME + " SET " + MEAL_NAME_COLUMN + " = '" + meal_name + "' WHERE " + MEAL_ID_COLUMN + " = " + mealId);
    }
}

Now, no matter if the activity is modifying 1 or 2 or even 3 tables, I’m able to update the meal’s name like so:

DatabaseManager.getInstance(context).mealsDBHelper.updateMealName(mealId, mealName);

Thats because the DatabaseManager contains a reference to all the other helper classes.

What I like about this approach is that I can simply access every table and do operations on it according to my needs, & what I don’t like is that the DatabaseManager class holds reference for all the helpers, and I’m not sure if its best to do so..

Second approach:

This approach does not saves all the helper classes inside the DatabaseManager.

DatabaseManager.java:

public class DatabaseManager extends SQLiteOpenHelper {
    private static String dbName = "logs.db";
    private static final int dbVersion = 1;

    private final Context context;

    private DatabaseManager(@NonNull Context context) {
        super(context, dbName, null, dbVersio);
        this.context = context.getApplicationContext();//Saving as application context to avoid leaks
    }

    private static DatabaseManager instance;
    public static synchronized DatabaseManager getInstance(Context context) {
        if (instance == null) {
            instance = new DatabaseManager(context);
        }
        return instance;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //...
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //...
    }
}

Now, if my activity needs to modify both ‘Meals’ & ‘MealFoods’ tables I can construct the helpers in onCreate, such as:

public class AddFoodActivity extends AppCompatActivity{

    MealsDBHelper mealsDBHelper;
    MealFoodsDBHelper mealFoodsDBHelper;

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

        mealsDBHelper = new MealsDBHelper(this);
        mealFoodsDBHelper = new MealFoodsDBHelper(this);
    }

    //Then whenever I need to modify the table I use:
    mealsDBHelper.updateMealName(mealId, mealName);
}

What I like about this approach is that I can use a simple line to modify a table according to my needs,
& what I don’t like is that I need to define helper references for every activity, and it kind of makes the code inconsistent.

Basically are there any downsides for using one of the methods?

I’ll admit I did leave a big chunk of code out of this post, but its only because I think it won’t add a lot to your understanding of the problem, because its a more general one.

Thank you very much for any kind of help.

java – Comparar dos horas Android

**Quisiera saber como puedo comparar dos horas de manera correcta en Android.
He estado leyendo, y pues econtré una posible solución.

Método:

private boolean horas(){
    //para la hora actual
    Calendar actual = Calendar.getInstance();
    actual.get(Calendar.HOUR);
    actual.get(Calendar.MINUTE);

    //para la hora final
    Calendar fin = Calendar.getInstance();
    fin.set(Calendar.HOUR, 12);
    fin.set(Calendar.MINUTE, 39);

    if(actual.equals(fin) || actual.after(fin)){
        carga.setEnabled(false);
        return true;
    }else{
        carga.setEnabled(true);
        return false;
    }
}

onCreate:

    if(horas() == true){
        Toast.makeText(ListaPreciosActivity.this, "Lo sentimos, las cargas y modificaciones de precio solo se pueden realizar hasta las 20:00 hs.", Toast.LENGTH_SHORT).show();
    }else{
        carga.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cargarPrecio();
            }
        });
    }

La idea es que luego de la hora indicada, se inhabilite el botón pero no me ha funcionado. ¿Qué estoy haciendo mal?

Why does my phone stop sending me Chase Android notifications?

I set up my Chase app on my Galaxy S8+ to send me an Android notification whenever money leaves my account. This was working fine up until about 2 or 3 years ago, then it became buggy.

I recently formatted my phone to try to solve this problem so that I’d have a fresh start. The notifications were coming in just fine and I was thrilled! However, just today they’ve stopped coming in when I spend money and I’m not sure why. I don’t remember making any major changes to my phone in the last few days either.

Does anyone have a list of things I could check to figure out why I’m not receiving them anymore? And is anyone else having this problem??

wi fi – How to hide your SSID from apps / keep your Android apps from finding your Wifi SSID?

As far as I know, all android apps are able to scan nearby / available Wifi networks. They can either get a list of nearby SSIDs, or at least they can get the SSID of the Wifi you are currently on. Correct? I remember the “get wifi scan results” unrevokable permission from some time ago (stoppable only if you were rooted and had xposed framework) (Also, exhibit B: Google, SkyHook, and Apple SSID databases).

This means that even if you are on a VPN, even if you turn off wifi scanning, even if you turn off location services and take out your sim card, even if you stop broadcasting your router’s wifi SSID, your apps will be able to know what wifi SSID you are currently on.

This means that an attacker (read: the surveillance capitalism 🙂 ), can figure out if/when I am home, and which other devices that are/were online have used the same SSID. E.g. all my family’s (mandatory) banking apps will know where my family members congregate, and could change my insurance score, or other “insert dystopian scenario here”.

Considering what I described, I don’t think there is any wiggle room for you to ever hide your real location from a bad (state, corp, hacker) actor. Am I wrong? Can I hide my SSID from the apps that are on my phone?

I can’t believe there aren’t any hits on this subject on the internet.

(PS: obviously, the point of the question is not whether or not I am paranoid, the question is whether this is technically solvable)

android studio – Escalar VideoView al máximo

como puedo hacer para que mi video se muestre en su tamaño máximo de forma proporcionada es decir que sus bordes choquen con los bordes de la pantalla, “no me refiero a pantalla completa”.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="10dp">                   
                           

                            
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="6dp"
        android:layout_weight="0"
        android:fontFamily="@font/font_regular"
        android:paddingTop="5dp"
        android:text="Texto One"
        android:textColor="@color/colorAccent"
        android:textSize="25sp" />

     </LinearLayout>

     <VideoView
         android:id="@+id/videoView2"
         android:layout_width="match_parent"
         android:layout_height="500dp"
         android:layout_gravity="center" />

Así esta en la parte de “desing”, agregue el cuadro marrón para indicar que así aparece al correr la app.

introducir la descripción de la imagen aquí

Deseo que quede con la parte GRIS pero al momento de ejecutarla app me aparece con la parte marrón. Espero se halla entendido mi idea “Deseo que el video se ajuste completamente a la pantalla, sin que pierda su proporción, o talvez que se recorte un poco pero que tome toda la pantalla en relacion a los bordes horizontales ya que un video en formato horizontal si logra visualizarse como deseo es decir sus bordes horizontales chocan con los bordes de la pantalla”, aclaro que no me refiero a que se reproduzca en pantalla completa.

Intente con match_parent en layout_width y layout_height igual con wrap_content pero no funciona,alintentar con estos en la parte visualse puede notar que no agrega ningún contenedor solo se encoje.
Para las imágenes uso esta propiedad, pero esta no esta disponible para VideoView

android:scaleType="centerCrop" 

Me encuentro en un fragmento aunque no creo que esto sea relevante en este caso.

java – Messaging Cloug Firebase não envia pra todos os aparelhos android

Olá.
Tenho um aplicativo Android que usa Cloud Messages, porem, notei que tenho alguns APP’s que a mensagem não chega.
Por exemplo, tenho X App’s ativos na playstore, porem, o Firebase me mostra uma quantidade diferente de Send.
Meu aparelho, por exemplo, chega apenas 1 vez, e em outros aparelhos que faço testes (Android 10) Chega corretamente.

Meu AndroidManifest.xml

”’

”’

Classe MyFirebaseInstanceIDService.java
”’
package com.joel.a0800restinga;

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

import static android.content.ContentValues.TAG;

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, “Refreshed token: ” + refreshedToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    //sendRegistrationToServer(refreshedToken);
}

}
”’

Classe MyFirebaseMessagingService.java
”’
package com.joel.a0800restinga;

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdReceiver;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

private static final String TAG = "MESSAGE_FB";

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // ...


    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());

        if (/* Check if data needs to be processed by long running job */ true) {
            // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
            //scheduleJob();
        } else {
            // Handle message within 10 seconds
            //handleNow();
        }

    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
    }

    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.
}

}
”’