Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

2020-09-26

Android Studio Complaining About Imports in "androidTest"

 If you are trying to build an androidTest with Android Studio and it can not find the classes being imported. (For example Android Studio can not find AndroidJUnit4, InstrumentationRegistry, etc.)


Like this, for example:

Change your Build Variant to debug.

This build variant "Release" causes the error from above.

This build variant "debug" solved the problem for me:


2020-07-18

AutoSOS: The Android SOS Alarm App for Emergencies

Photo by Aaron Burden on Unsplash

We are pleased to announce that we have just released a new version of our Android alerting app AutoSOS in Google's Play Store.

Basic Functionality

  • Alarming in case of emergency (via phone call and SMS with a link to Google Maps)
    • No Internet required, i.e. no need to purchase data packages for alerting (neither at home nor abroad).
    • Locating the alarming mobile phone with and without GPS (less accurate)
  • Speed dial and alarming from lock screen
  • Alerting of incoming alarm SMS, even in silent mode
  • Eases finding the mobile phone in close proximity, by making it ring through an SMS command, even in silent mode
  • Facilitate the location of the mobile phone in case of theft by reporting its current position:
    • in response to a SMS command 
    • when the SIM card is changed

Alarm triggering


Alarm can be raised:
  • by clicking on the SOS button
  • by pulling the earphone plug (Hint: Cut the cord of an old earphone and make a loop or knot.)
  • by absence of significant motion
  • by pressing the power button several times
  • by pressing a Flic button (to be bought separately from www.flic.io)
  • when the battery is low of charge

Details







2019-09-05

How To List Files in Google's Firebase Storage


This is an example of how to list the files stored in a given Storage Bucket (like a "folder") in Java under Android.

Follow Google's description "Get Started with Cloud Storage on Android" in order to configure Firebase Storage for your App.

For the detailed description of listing files (the example listed there uses Kotlin, not Java).

final String LOG_TAG = "MyTag"

// The first step in accessing your storage bucket is to create an instance of FirebaseStorage:
FirebaseStorage storage = FirebaseStorage.getInstance();

// ... or you also can specify a specific storage bucket (see document from the first URL from above)
// FirebaseStorage storage = FirebaseStorage.getInstance("gs://my-custom-bucket");

// Create a storage reference from our app
StorageReference storageRef = storage.getReference();

// Create a child reference. The myKindOfFolder now points to the "kind of subdirectory" containing the file(s) to be listed
storageRef.child("myKindOfFolder")
        .listAll()
        .addOnSuccessListener(new OnSuccessListener<ListResult>() {
            @Override
            public void onSuccess(@NonNull ListResult result) {
                Log.d(LOG_TAG, "onSuccess()");
                Iterator<StorageReference> i = result.getItems().iterator();
                StorageReference ref;
                while (i.hasNext()) {
                    ref = i.next();
                    Log.d(LOG_TAG, "onSuccess() File name: " + ref.getName());
                }
            }
        })
.addOnFailureListener(new OnFailureListener() {
    public void onFailure(@NonNull Exception e) {
        Log.er(LOG_TAG, "onFailure(): ", e);
    }
});

Output
. . .
. . . onSuccess() File name: File01.txt
. . . onSuccess() File name: File02.txt
. . . onSuccess() File name: File03.txt
. . .