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

Apps how to read files with NDK

Specifically, I am working on integrating StockFish with Android. The significant part of SF is its syzygy - directory where its tablebase is stored.These files are huge (about 1GB) and I do not want to include them in the program body. I want to allow the user to download them and specify their directory so that SF can use them. SF loads one of the files within this directory, one at a time, as needed.
StockFish is a shared library written in C++.
How can this be done with the current APIs?

Google Photos auto backup

Hi all, I have this Samsung A23 and my google photos wasn't backing up my photos for almost a year due to lack of space in the cloud. Recently I signed up google one and the backup of my photos started working again... But the photos are not being backed up automatically as it was before. I mean, when I open the Photos app, it starts backing up. But if I close the app, the backup just stops. As far as I know, I never had to open the Photos app to backup. My photos used to backup almost instantly. But this is not happening anymore. Any clues? Maybe some configuration out of the Photos app?

Thanks for the help!

Remote Spyware?

OK, I'm not technical AT ALL so please excuse me.

Is it possible for a device to be infected remotely with spyware via a photo/video sent via a chat site like Snapchat/Kik?

I have a few anti-virus apps - Norton paid for, AVG and Malwarebytes. These should catch anything nasty right?

Apps Android studio flamingo asking for compileSdkVersion to be set to 34

I have an app that is built using capacitorjs. Now I have updated the capacitor js version to be 5 along with android studio updated with flamingo. Since the update, I get below error:

Dependency 'androidx.core:core:1.12.0-alpha05' requires libraries and applications that
depend on it to compile against version 34 or later of the
Android APIs.

:app is currently compiled against android-33.

Also, the maximum recommended compile SDK version for Android Gradle
plugin 8.0.0 is 33.

Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 34, then update this project to use
compileSdk of at least 34.

Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).

I now updated compileSdkVersion to 34 in :app build.gradle file. and it works fine.

Since 34 is still in dev, will it cause problems for my app? Should I be doing this? Any suggestions?

Setting up a RecyclerView

Noobie here.
I am working on my first app using a Recyclerview. I have an Adapter (SongsAdapter) to make it work. This is my code for the Adapter>

package com.example.musiclyrics;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.snackbar.Snackbar;

public class SongsAdapter extends RecyclerView.Adapter<SongsAdapter.ViewHolder> {
private Context context;
private Cursor cursor;

public SongsAdapter(Context context) {
this.context = context;
}
public void setCursor(Cursor cursor) {
this.cursor = cursor;

notifyDataSetChanged();
cursor.moveToFirst(); // Move cursor to the first row
ViewHolder holder = onCreateViewHolder(null, 0);

onBindViewHolder(holder, 0);
}

@override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.songs_layout, parent, false);
return new ViewHolder(view);
}

@override
public void onBindViewHolder(ViewHolder holder, int position) {

if (cursor != null && cursor.moveToPosition(position)) {

int songNameIndex = cursor.getColumnIndex("SONG_NAME");
int artistIndex = cursor.getColumnIndex("ARTIST");
int durationIndex = cursor.getColumnIndex("DURATION");
int songIdIndex = cursor.getColumnIndex("KEY_ID");

String songName = cursor.getString(songNameIndex);
String artist = cursor.getString(artistIndex);
String duration = cursor.getString(durationIndex);
final int songId = cursor.getInt(songIdIndex);

holder.songNameTextView.setText(songName);
holder.artistTextView.setText(artist);
holder.durationTextView.setText(duration);

holder.itemView.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
// MainActivity.varCurrentSong = songId;
// Handle the click event
}
});
}
cursor.moveToNext()

}

@override
public int getItemCount() {
return (cursor != null) ? cursor.getCount() : 0;
}

public static class ViewHolder extends RecyclerView.ViewHolder {
TextView songNameTextView;
TextView artistTextView;
TextView durationTextView;

public ViewHolder(View itemView) {
super(itemView);
songNameTextView = itemView.findViewById(R.id.txt_songName);
artistTextView = itemView.findViewById(R.id.txt_Artist);
durationTextView = itemView.findViewById(R.id.txt_Duration);
}
}
}

At runtime this appears to work OK but the screen only shows the first record. I have tried about 50 different ideas and suggestions on how to make this work to no avail. Can someone help me out please?
Thanks

Nokia c100 hard reset/pattern bypass

I have a Nokia c100 that has a pattern lock. I need to be able to get in to the phone or hard reset. data preservation not necessary. I tried using the boot loader (holding down power/volume up or/and down, all combinations), nothing. All I got was a small white “fast boot mode” on bottom left of screen. Is this phone trash unless you know the code? I’ve seen a few videos saying it’s impossible, but wanted to see what other people think.
Thanks for all the help!
-Sam

Separated Dad needs to give 4year old and 7 year old a tablet to video chat with me

I am wondering if you guys have any suggestions as to what I can do to prevent them from opening any other aps. I don't want them to download or visit anything on that tablet. I want them to have direct communication with me. Luckily the mom doesn't have a problem with this.

I use Nova Launcher, have used it for years, but its always the same settings for my business. I know I can lock the screen from moving apps etc...
Do you guys know if there is a place, dedicated to child safety features?

Basically I just want to have 1 button on the main screen for them to call or video call (i guess 2 buttons) and that's it. I can do that part. but not child proofing

Butterfly Watch Face

Just released: Butterfly Watch Face

With free & premium features : more than 50 backgrounds, custom colors, 8 datas & infinite data with complications.
Secondary timezone, a lot of possibilities for ambient mode, and many other features to discover!

I hope that you will like it!

mcSAye9m.jpg
3l5D9sfm.jpg

LRYYdx2m.jpg
Ri13efwm.jpg

Integrate Google sign-in into an app

Hi,
I'm currently building an app, and one way to login/create an account is to use your existing Google account. Google does provide quite a few documents on how to do it, but once you get to the API part with the OAuth consent screen, it starts to get a bit confusing.

They require us to choose between an internal (Only available to users within your organization) and external (Available to any test user with a Google Account.) user type. External is the only option that can be selected for me, and that starts to make things difficult.
They require us to provide an app name, a logo, and a bunch of information that I don't have yet. All I want to do is test the Google sign-in method and see how I can integrate it in the future in a more serious project.

Is there any way to do this? Or do I have to provide them with all of this extra information?

Thanks

How to connect Android to WiFi and network in the same time

I need Android to connect to both WiFi and the 4G Network in the same time.
As known, the default setting makes Android disconnect from the network once it connects to WiFi,
therefore it can't connect to both simultaneously.

There is an app in the Google app store called Speedify which does this:

But I would prefer to do it myself if possible. I checked on the net and some suggest to edit the 'ConnectivityServices.java' file;
however, I couldn't find yet the solution that works for sure.

Some suggest some editings in the ConnectivityServices.java file, but I couldn't find yet the solution that works for sure.

I would appreciate any help on how to achieve this.

Where are recorded alarm sounds stored in Android 13

The alarm feature on the Android 13 clock has added the excellent new feature to record sounds and use them as alarms. I'd like to use some of these alarms elsdewhere, but I can't find them.

The alarm shows as the day of the week and time of day that it was recorded, but I can find no corresponding file anywhere in my storage.

On exploring the "Alarm sound" screen, the alarm shows under "Sounds" ("Sunday at 01:50"), but is not in the "Ringtones" folder where all the other alarm sounds are to be found. The 3-dot menu reveals only a "Remove" option.

Can anybody tell me where these sound files are stored?

Screenshots below.

Attachments

  • Screenshot_20230606-143712.png
    Screenshot_20230606-143712.png
    200.6 KB · Views: 254
  • Screenshot_20230606-144028.png
    Screenshot_20230606-144028.png
    187.4 KB · Views: 124

Receive sms on my app from specific number

if (checkPermission()) {
btn1.setEnabled(true);
} else
{
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, SEND_SMS_PERMISSION_REQ);
}
btn1.setOnLongClickListener(this);
btn2.setOnLongClickListener(this);
btn3.setOnLongClickListener(this);
btn4.setOnLongClickListener(this);
btnState.setOnLongClickListener(this);
btnVanne.setOnLongClickListener(this);
}
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(messageReceiver);
}

public void login(View view) {
}

class MessageReceiver extends BroadcastReceiver {
public static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
private static final String SMS_SENDER = "0000000000000";
@override
public void onReceive(Context context, Intent intent) {
if (intent != null && intent.getAction() != null &&
ACTION.compareToIgnoreCase(intent.getAction()) == 0) {
Object[] pduArray = (Object[]) intent.getExtras().get("pdus");
SmsMessage[] messages = new SmsMessage[pduArray.length];
for (int i = 0; i < pduArray.length; i++) {
messages = SmsMessage.createFromPdu((byte[]) pduArray);
}
String sms_from = messages[0].getDisplayOriginatingAddress();
if (sms_from.equals(SMS_SENDER)) {
StringBuilder bodyText = new StringBuilder();
for (SmsMessage message : messages) {
bodyText.append(message.getMessageBody());
}
String body = bodyText.toString();
ReceivedSms.setText(body);
abortBroadcast();
}
}

}
}
private boolean checkPermission() {
return false;
}

How to run/invoke Instrumented Tests from within Android App code (MainActivity)

In the current arrangement, on Android, Instrumented Tests can be invoked by following approaches:

  1. From within Android Studio -> Right click on the class saved under "androidTest"
  2. Fire command adb shell am instrument -w com.example.testing/androidx.test.runner.AndroidJUnitRunner on CMD prompt.
But mine is unique requirement. As per my requirement, I would like to Run/Invoke these test cases (written inside classes saved under androidTest) from UI of the App code itself i.e. when user clicks on a button presented on the UI, the respective test case(s) get executed.

Following is the code written in "ExampleInstrumentedTest" saved under "androidTest" Folder:

Code:
package com.example.myapplication

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.uiautomator.UiDevice

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun testCaseForButton1() {
        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
        //Filler step
        assertEquals("com.example.myapplication", appContext.packageName)
    }

    @Test
    fun testCaseForButton2() {
        val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
        //Filler step
        assertEquals("com.sec.android.app.launcher", device.launcherPackageName)
    }
}


Code in MainActivity():

Code:
override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        findViewById<Button>(R.id.buttonRunTest1)
            .setOnClickListener {
                //Invoke testCaseForButton1
            }

        findViewById<Button>(R.id.buttonRunTest2)
            .setOnClickListener {
                //Invoke testCaseForButton2
            }
    }


I read somewhere that "instrumented" tests can not be called/triggered from within App code. Also tried but failed with error "No instrumentation registered! Must run under a registering instrumentation"

Request help with code to be written inside the "OnClickListener".

Tried couple of approaches:

Code:
// Code to execute when the button is clicked
fun startTest(){
   val packageName = "com.example.myapplication"
   val testRunnerClass = "androidx.test.runner.AndroidJUnitRunner"
   val command = "am instrument -w $packageName/$testRunnerClass"
   Runtime.getRuntime().exec(command)
}


Code:
// Code to execute when the button is clicked
fun startTest(){
   val instrumentation = InstrumentationRegistry.getInstrumentation()
   val paramTypes = arrayOf(ComponentName::class.java, Bundle::class.java)
   val method = instrumentation.javaClass.getDeclaredMethod("startInstrumentation", *paramTypes)
}


My build.gradle:

Code:
    {
        ....
        defaultConfig {
            applicationId "com.example.myapplication"
            minSdk 28
            targetSdk 32
            versionCode 1
            versionName "1.0"

            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            ....
    }

Dependencies in build.gradle:

Code:
dependencies {
    ...
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    implementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    ...
}


But nothing works. Ideally, it should invoke respective instrumented test cases.

How to download and install Plantronics Hub (PLT HUB) which is no longer in the Play Store

My Samsung phone no longer has Plantronics Hub aka PLT HUB, a great app to control my old Plantronics BT headset. How may I install this app if it's not in the Play Store? The current version, Poly Lens, will not work with the bluetooth set, but Plantronics Hub will work.

I have PLT Hub on one Android phone. Can it be transferred to the other phone? If so, how?

Thanks.

Filter

Back
Top Bottom