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

Help Auto refresh problem with Display

Hello all,

I have a problem with Android that I hope someone here knows a solution.

We have a display from China that runs on Android 7.0, which seems to refresh every so many minutes (automatically). If I open a browser then you see that that page is reloaded automatically (not a problem in itself), but also if I have an app open that should actually be visible on that display all day, then the refresh also seems to finish the app to close. See the video here;

Is anyone familiar with what this can be and how I can fix it?

Many thanks in advance!

Attachments

  • WhatsApp Image 2019-06-06 at 16.24.48.jpeg
    WhatsApp Image 2019-06-06 at 16.24.48.jpeg
    93.3 KB · Views: 172

Apps BluetoothDevice.createrfcommsockettoservicerecord is Null

I have successfully recognised the bluetooth device (HC-05), I got its name, MAC address, and bond state, but when I'm trying to create a client socket in order to initiate a bluetooth connection with it I got a null socket.

This is my code:

//initializing bluetooth adapter
val bluetoothAdapter: BluetoothAdapter? = BluetoothAdapter.getDefaultAdapter()
if (bluetoothAdapter?.isEnabled == false) {
val enableBtIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT)
}

//creating a list of PAIRED DEVICES
val pairedDevices: Set<BluetoothDevice>? = bluetoothAdapter?.bondedDevices

//define a BluetoothDevice (the first on the list)
pairedDevices?.forEach { device ->
val deviceName = device.name
val deviceHardwareAddress = device.address // MAC address
val arduino: BluetoothDevice = pairedDevices.first()

Then i try:

val arduinoSocket = arduino?.createRfcommSocketToServiceRecord(uuid)

which is null.

The UUID is:
private val uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB")

Any insights? Thanks

How can I get the CPU load in a multi-core android device?

As a student, I have a project where I must analyze the CPU load of every core in multi-core and Big.little architectures. I execute some applications on recent Android devices (Oreo 8.0). From what I've seen on the internet, it seems that the CPU load (average and detailled for each core) is not available anymore to developers. Therefore, it is impossible for me to analyze it, unless I try to root all my devices to unlock features.

I currently have 3 devices: a Samsung A5 (2017), a Samsung A7 (2018) and a LG Nexus 5X. I can't access the CPU load for any of those devices.

I've tried the following code to access the data related to the CPU utilization.

RandomAccessFile reader = new RandomAccessFile("/proc/stat", "r");

This should give me information about the CPU, and it only gives me an exception.

java.io.FileNotFoundException: /proc/stat: open failed: EACCES (Permission denied)

Is there any other way to access this information (average CPU load and the detailled load for each core)? Or do I have to root my devices and hope it solves my problem?

Please Recommend Backup App

I have an Android Media Player device running v7.1. It is a Zidoo Z9S to be specific. I have one 10TB drive hooked up via USB and I would like to add a second drive to back up the media drive on a periodic basis. I actually want a delay, so I do not want to replicate the media drive in real time like a RAID mirror.

So I am looking for an app that will backup from one drive to the other on a configurable, periodic basis. Most of the apps I've looked at so far are designed for phones and to back up the system, settings, apps. I don't want to do that, I want an external drive to external drive backup.

Can anyone recommend anything that hits the spot? I don't mind purchasing a solid, trustworthy, legitimate app. I do not want anything ad supported or anything sketchy even if it's "free".

Random Group Chats Created

I'm in week 2 of my Galaxy S10 5G.

Tonight, anytime I send an image via text to a single recipient, the phone is randomly creating group chats, adding 1 to 3 people from my contacts list and creating a conversation starting with the image. It also may or may not add random images to the chat conversation with the originally intended pic.

I've scanned for a virus as it started after sending a GIF comment to someone via the keyboard library. Phone is clean according to AVG.

I've rebooted. I've googled but nobody seems to be having this particular issue. Thoughts??

Pillow Speaker

Hello Android Forum I was wondering if someone has had a similar issue with their pillow speaker. I want my LG G4 to send the same amount of power to the external pillow speaker as it sends to the internal speaker. When I plug in my external speaker, it is barely audible compared to the internal speaker that has good sound volume and can be heard from a distance.

[DOOGEE X10] [TWRP] Need help!!! I want to port TWRP into my DOOGEE X10

Alright, gonna give tons of informations, 'cause need to root my DOOGEE X10 [I can't even change my font, also phone came with preinstall malware programs (adups.fota*)]



USE CTRL+F to find required info



------ DiskInfo ------

--- INTERNAL STORAGE ---



--hmzram0 [Swap] - 332MB

Not mounted



--- INTERNAL STORAGE (MLC-NAND) ---



--preloader mtdblock0 - 18 MB

Not mounted

--pro_info mtdblock1 - 12 MB

Not mounted

--nvram mtdblock2 - 48 MB

Not mounted

--protect_f mtdblock3 (/protect_f,... - 18 MB

16,1 MB used - 1,9 MB free

--seccnfg mtdblock4 - 12 MB

Not mounted

--uboot mtdblock5 - 12 MB

Not mounted

--boot mtdblock6 - 18 MB

Not mounted

--recovery mtdblock7 - 18 MB

Not mounted

--secstatic mtdblock8 - 12 MB

Not mounted

--misc mtdblock9 - 18 MB

Not mounted

--logo mtdblock10 - 12 MB

Not mounted

--md1img mtdblock11 - 54 MB

Not mounted

--nvcfg mtdblock12 (/nvcfg) [rawfs] - 18 MB

16,1 MB used - 1,9 MB free

--expdb mtdblock13 - 18 MB

Not mounted

--system mtdblock14 - 1,2 GB

Not mounted

--userdata mtdblock15 - 5,1 GB



--- UBIFS ---



--/data [ubifs] - 4,4 GB

1010 MB used - 3,4 GB free

--/system [ubifs] - 1 GB

997 MB used - 68,2 MB free

--/cache [ubifs] - 225 MB

276 KB used - 225 MB free



--- TMPFS MOUNT POINTS ---



--/dev [tmpfs] - 221 MB

88 KB used - 221 MB free

--/mnt [tmpfs] - 221 MB

0 B used - 221 MB free

--/storage [tmpfs] - 221 MB

0B used - 221 MB free

--/storage/self [tmpfs] - 221 MB

0B used - 221 MB



--- MEMORY ---


Alright, gonna give tons of informations, 'cause need to root my DOOGEE X10 [I can't even change my font, also phone came with preinstall malware programs (adups.fota*)]



USE CTRL+F to find required info



------ DiskInfo ------

--- INTERNAL STORAGE ---



--hmzram0 [Swap] - 332MB

Not mounted



--- INTERNAL STORAGE (MLC-NAND) ---



--preloader mtdblock0 - 18 MB

Not mounted

--pro_info mtdblock1 - 12 MB

Not mounted

--nvram mtdblock2 - 48 MB

Not mounted

--protect_f mtdblock3 (/protect_f,... - 18 MB

16,1 MB used - 1,9 MB free

--seccnfg mtdblock4 - 12 MB

Not mounted

--uboot mtdblock5 - 12 MB

Not mounted

--boot mtdblock6 - 18 MB

Not mounted

--recovery mtdblock7 - 18 MB

Not mounted

--secstatic mtdblock8 - 12 MB

Not mounted

--misc mtdblock9 - 18 MB

Not mounted

--logo mtdblock10 - 12 MB

Not mounted

--md1img mtdblock11 - 54 MB

Not mounted

--nvcfg mtdblock12 (/nvcfg) [rawfs] - 18 MB

16,1 MB used - 1,9 MB free

--expdb mtdblock13 - 18 MB

Not mounted

--system mtdblock14 - 1,2 GB

Not mounted

--userdata mtdblock15 - 5,1 GB



--- UBIFS ---



--/data [ubifs] - 4,4 GB

1010 MB used - 3,4 GB free

--/system [ubifs] - 1 GB

997 MB used - 68,2 MB free

--/cache [ubifs] - 225 MB

276 KB used - 225 MB free



--- TMPFS MOUNT POINTS ---



--/dev [tmpfs] - 221 MB

88 KB used - 221 MB free

--/mnt [tmpfs] - 221 MB

0 B used - 221 MB free

--/storage [tmpfs] - 221 MB

0B used - 221 MB free

--/storage/self [tmpfs] - 221 MB

0B used - 221 MB



--- MEMORY ---



--RAM - 443 MB

310 MB used - 132 MB free

--Swap - 332 MB

275 MB used - 56,4 MB free


------ AIDA64 ------
--- System ---



Manufacturer - DOOGEE

Model - DOOGEE X10

Brand - DOOGEE

Device - doogee-X10

Hardware - mt6570

Platform - mt6570

Product - doogee-X10

Serial - [NOT SHOWING]

Installed RAM - 512MB

Total Memory - 443 MB

Available Memory - 148 MB

Internal Storage Total Space - 4481 MB

Internal Storage Free Space - 3467 MB

Bluetooth Version - 4+



--Device Features:

android.hardware.audio.output

android.hardware.bluetooth

android.hardware.bluetooth_le

android.hardware.camera

android.hardware.camera.any

android.hardware.camera.autofocus

android.hardware.camera.flash

android.hardware.camera.front

android.hardware.faketouch

android.hardware.location

android.hardware.location.gps

android.hardware.location.network

android.hardware.microphone

android.hardware.screen.landscape

android.hardware.screen.portrait

android.hardware.sensor.accelerometer

android.hardware.sensor.light

android.hardware.sensor.proximity

android.hardware.telephony

android.hardware.telephony.gsm

android.hardware.touchscreen

android.hardware.touchscreen.multitouch

android.hardware.touchscreen.multitouch.distinct

android.hardware.usb.accessory

android.hardware.wifi

android.hardware.wifi.direct

android.software.app_widgets

android.software.backup

android.software.connectionservice

android.software.device_admin

android.software.home_screen

android.software.input_methods

android.software.live_wallpaper

android.software.midi

android.software.print

android.software.webview

com.google.android.feature.FASTPASS_BUILD



--- CPU ---



SoC Model - MediaTek MT6570

Core Architecture - 2x ARM Cortex-A7 @ 1300 MHz

Manufacturing Process - 28 nm

Instruction Set - 32-bit ARMv7

CPU Revision - r0p3

CPU Cores - 2

CPU Clock Range - 604 - 1300 MHz

Core 1 Clock - 1300 MHz

Core 2 Clock - 1300 MHz

CPU Utilization - 100 %

Scaling Governor - interactive

Supported ABIs - armeabi-v7a, armeabi

Supported 32-bit ABIs - armeabi-v7a, armeabi

AES - Not Supported

NEON - Supported

SHA1 - Not Supported

SHA2 - Not Supported



--- Display ---



Screen Resolution - 480 x 854

Panel ID - rm68172_boe50_xingliang_fwvga

xdpi / ydpi - 240 / 240 dpi

GPU Vendor - ARM

GPU Rendered - MALI-400 MP

GPU Cores - 1

Refresh Rate - 57 Hz

Default Orientation - Portrait

OpenGL ES Version - 2.0



--OPENGL ES Extensions

GL_EXT_debug_marker

GL_OES_texture_npot

GL_OES_vertex_array_object

GL_OES_compressed_ETC1_RGB8_texture

GL_EXT_compressed_ETC1_RGB8_sub_texture

GL_OES_standard_derivatives

GL_OES_EGL_images

GL_OES_depth24

GL_ARM_rgba8

GL_ARM_mali_shader_binary

GL_OES_depth_texture

GL_OES_packed_depth_stencil

GL_EXT_texture_format_BGRA8888

GL_OES_vertex_half_float

GL_EXT_blend_minmax

GL_OES_EGL_image_external

GL_OES_EGL_sync

GL_OES_rgb8_rgba8

GL_EXT_multisampled_render_to_texture

GL_EXT_discard_framebuffer

GL_OES_get_program_binary

GL_ARM_mali_program_binary

GL_EXT_shader_texture_lod

GL_EXT_robustness

GL_OES_depth_texture_cube_map

GL_KHR_debug

GL_ARM_shader_framebuffer_fetch

GL_ARM_shader_framebuffer_fetch_depth_stencil



--- Android ---



Android Version - 6.0 (Marshmallow)

API Level - 23

Android Security Patch Level - 2017-07-05

Rooted Device - No

Android ID - [NOT SHOWING]

Baseband - MOLY.WR8.W1449.MD.WG.MP.V111.4.P1, 2017/06/16 10:48

Build ID - DOOGEE-X10-Android6.0-20170921

Codename - REL

Fingerprint - DOOGEE/doogee-X10/doogee-X10:6.0/MRA58K/20170608.142922:user/release-key

ID - MRA58K

Incremental - 1505963999

Java Runtime Version - Android Runtime 0.9

Java VM Version - ART 2.1.0

Java VM Heap Size - 128 MB

Kernel Architecture - armv7l

Kernel Version - 3.18.35 (user@linux-user) (gcc bersion 4.8 (GCC) ) #2 SMP PREEMPT Thu Sep 21 12:50:51 CST 2017

Tags - release-keys

Type - user

Google Play Services Version - 17.1.22 (040304-245988633)

OpenSSL Version - BoringSSL

ZLib Version - 1.2.8

ICU CLDR Version - 27.0.1

ICU Library Version - 55.1

ICU Unicode Version - 7.0

Android Language - [STILL DON'T CARE]

Configured Time Zone - [STILL DON'T CARE]

UpTime - [STILL DON'T CARE]



--- Devices ---



--USB Device - Linux 3.18.35 musb-hcd MUSB HDRC host driver--

Manufacturer - Linux 3.18.35 musb-hdc





[[SUPER TIRED OF WRITING] Hopefully that's enough.
--RAM - 443 MB

310 MB used - 132 MB free

--Swap - 332 MB

275 MB used - 56,4 MB free



------ AIDA64 ------

--- System ---



Manufacturer - DOOGEE

Model - DOOGEE X10

Brand - DOOGEE

Device - doogee-X10

Hardware - mt6570

Platform - mt6570

Product - doogee-X10

Serial - [NOT SHOWING]

Installed RAM - 512MB

Total Memory - 443 MB

Available Memory - 148 MB

Internal Storage Total Space - 4481 MB

Internal Storage Free Space - 3467 MB

Bluetooth Version - 4+



--Device Features:

android.hardware.audio.output

android.hardware.bluetooth

android.hardware.bluetooth_le

android.hardware.camera

android.hardware.camera.any

android.hardware.camera.autofocus

android.hardware.camera.flash

android.hardware.camera.front

android.hardware.faketouch

android.hardware.location

android.hardware.location.gps

android.hardware.location.network

android.hardware.microphone

android.hardware.screen.landscape

android.hardware.screen.portrait

android.hardware.sensor.accelerometer

android.hardware.sensor.light

android.hardware.sensor.proximity

android.hardware.telephony

android.hardware.telephony.gsm

android.hardware.touchscreen

android.hardware.touchscreen.multitouch

android.hardware.touchscreen.multitouch.distinct

android.hardware.usb.accessory

android.hardware.wifi

android.hardware.wifi.direct

android.software.app_widgets

android.software.backup

android.software.connectionservice

android.software.device_admin

android.software.home_screen

android.software.input_methods

android.software.live_wallpaper

android.software.midi

android.software.print

android.software.webview

com.google.android.feature.FASTPASS_BUILD



--- CPU ---



SoC Model - MediaTek MT6570

Core Architecture - 2x ARM Cortex-A7 @ 1300 MHz

Manufacturing Process - 28 nm

Instruction Set - 32-bit ARMv7

CPU Revision - r0p3

CPU Cores - 2

CPU Clock Range - 604 - 1300 MHz

Core 1 Clock - 1300 MHz

Core 2 Clock - 1300 MHz

CPU Utilization - 100 %

Scaling Governor - interactive

Supported ABIs - armeabi-v7a, armeabi

Supported 32-bit ABIs - armeabi-v7a, armeabi

AES - Not Supported

NEON - Supported

SHA1 - Not Supported

SHA2 - Not Supported



--- Display ---



Screen Resolution - 480 x 854

Panel ID - rm68172_boe50_xingliang_fwvga

xdpi / ydpi - 240 / 240 dpi

GPU Vendor - ARM

GPU Rendered - MALI-400 MP

GPU Cores - 1

Refresh Rate - 57 Hz

Default Orientation - Portrait

OpenGL ES Version - 2.0



--OPENGL ES Extensions

GL_EXT_debug_marker

GL_OES_texture_npot

GL_OES_vertex_array_object

GL_OES_compressed_ETC1_RGB8_texture

GL_EXT_compressed_ETC1_RGB8_sub_texture

GL_OES_standard_derivatives

GL_OES_EGL_images

GL_OES_depth24

GL_ARM_rgba8

GL_ARM_mali_shader_binary

GL_OES_depth_texture

GL_OES_packed_depth_stencil

GL_EXT_texture_format_BGRA8888

GL_OES_vertex_half_float

GL_EXT_blend_minmax

GL_OES_EGL_image_external

GL_OES_EGL_sync

GL_OES_rgb8_rgba8

GL_EXT_multisampled_render_to_texture

GL_EXT_discard_framebuffer

GL_OES_get_program_binary

GL_ARM_mali_program_binary

GL_EXT_shader_texture_lod

GL_EXT_robustness

GL_OES_depth_texture_cube_map

GL_KHR_debug

GL_ARM_shader_framebuffer_fetch

GL_ARM_shader_framebuffer_fetch_depth_stencil



--- Android ---



Android Version - 6.0 (Marshmallow)

API Level - 23

Android Security Patch Level - 2017-07-05

Rooted Device - No

Android ID - [NOT SHOWING]

Baseband - MOLY.WR8.W1449.MD.WG.MP.V111.4.P1, 2017/06/16 10:48

Build ID - DOOGEE-X10-Android6.0-20170921

Codename - REL

Fingerprint - DOOGEE/doogee-X10/doogee-X10:6.0/MRA58K/20170608.142922:user/release-key

ID - MRA58K

Incremental - 1505963999

Java Runtime Version - Android Runtime 0.9

Java VM Version - ART 2.1.0

Java VM Heap Size - 128 MB

Kernel Architecture - armv7l

Kernel Version - 3.18.35 (user@linux-user) (gcc bersion 4.8 (GCC) ) #2 SMP PREEMPT Thu Sep 21 12:50:51 CST 2017

Tags - release-keys

Type - user

Google Play Services Version - 17.1.22 (040304-245988633)

OpenSSL Version - BoringSSL

ZLib Version - 1.2.8

ICU CLDR Version - 27.0.1

ICU Library Version - 55.1

ICU Unicode Version - 7.0

Android Language - [STILL DON'T CARE]

Configured Time Zone - [STILL DON'T CARE]

UpTime - [STILL DON'T CARE]



--- Devices ---



--USB Device - Linux 3.18.35 musb-hcd MUSB HDRC host driver--

Manufacturer - Linux 3.18.35 musb-hdc

[[SUPER TIRED OF WRITING] Hopefully that's enough.

Menu for fragment when using SectionsStatePageAdapter

I followed a video
tutorial on creating fragments making use of a ViewPager & SectionsStatePageAdapter. (By ordering comments on this YouTube video by NEW first, you can see my comments to the developer under the user 'Shaun')
Subsequently I have tried adding a menu into my main fragment.

In my fragment_main_layout.xml I have the following code (along with any buttons definitions, etc.) These all show up in the Design view of the fragment, as well as when the app is running. It is however just a plain toolbar, and I want to add items to the toolbar, like a menu icon. I can't get this menu icon to show though.

Code:
<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/logoGreen"
    android:minHeight="?attr/actionBarSize"
    app:layout_constraintTop_toTopOf="parent"
    tools:layout_editor_absoluteX="0dp" />

I also created a menu called top_menu.xml under res\menu folder, adding into the definition the icon, title, id & showAsAction. When I view this in Design view, it shows a toolbar with the icon, as well as the name of the app.

Code:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res-auto">

    <item android:id="@+id/menu_item_settings"
        android:icon="@drawable/ic_menu"
        android:title="test"
        myapp:showAsAction="always" />
</menu>

In my FragmentMain.java file I have the following 2 mothods:

Code:
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    Log.i(TAG, "msg1");
    setHasOptionsMenu(true);
    Log.i(TAG, "msg2");
    View view = inflater.inflate(R.layout.fragment_main_layout, container, false);
    btnNavFragInnovations = (Button) view.findViewById(R.id.button1);
    btnNavFragTraining = (Button) view.findViewById(R.id.button2);
    btnNavFragForms = (Button) view.findViewById(R.id.button3);

    Log.i(TAG, "myMsg");
    btnNavFragInnovations.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ((MainActivity)getActivity()).setmViewPager(1);
        }
    });

    btnNavFragTraining.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ((MainActivity)getActivity()).setmViewPager(2);
        }
    });

    btnNavFragForms.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ((MainActivity)getActivity()).setmViewPager(3);
        }
    });

    return view;
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
    Log.i(TAG, "OnCreateOptionsMenu");
    menuInflater.inflate(R.menu.top_menu, menu);
    super.onCreateOptionsMenu(menu, menuInflater);
}

However, by monitoring the LogCat, this onCreateOptionsMenu method never gets called, and the toolbar with the menu icon is never created in the fragment, just the original one created in the fragment_main_layout.xml file.

[FIXED]Google accounts not syncing, google play store not working, tried many solutions. How to fix?

Edit: Fixed the issue by going to accounts.google.com on a browser and completing the security steps.

I'm using a Samsung Galaxy On5 phone.

My google accounts arent syncing properly. Under Settings > Accounts > Google, it says "Sync is currently experiencing problems. It will be back shortly". However, it's been at least 48 hours since this problem has started and it still isn't "back".

I cannot log in on youtube or gmail. Opening Google Docs documents don't work. Duolingo won't load. Brawl Stars too. I've tried clearing data and cache for Google Play, Gmail, Youtube and it won't let me sign in to any account.

The Play Store would say that "Authentication is required." I uninstalled updates for it to no avail.

Gmail wouldn't load new emails, I tried sending an email to myself. It stayed as "Queued". I reset the cache and data for the Gmail app. When I opened it, it prompted me to set up an email. I clicked "Add Account", and it opened a list of email providers. I clicked on "Google" and nothing happened. I clicked on "Other" instead and entered my gmail account, but clicking "Next" did nothing. I clicked on "Manual Setup" under the email field and tried to set up my email manually, but it said "Can't connect to server".

I've looked online for answers. I found nothing useful. I tried everything. My date and time are properly set. I tried setting it to a wrong date on purpose, then re-enabling automatic date settings, but nothing happened. I cleared data and cache for my google apps. Didn't fix it. I've tried restarting my device. No power saving settings are turned on. All apps have no data restrictions. I reset all my app preferences.

I've tried everything. I have no idea what else I can do other than factory resetting, which I don't want to do. Please help. Thank you so much.

Edit: Fixed the issue by going to accounts.google.com on a browser and completing the security steps.

Errors when I try to run my app

I seem to be completely snookered now. When I try to run my fledgling app in a Pixel 3 VM I get the following in the error log:

14:08 Emulator: C:\Users\name\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: -drive if=none,index=2,id=userdata,file=C:\Users\name\.android\avd\Pixel_3_API_Q.avd\userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576: Could not open 'C:\Users\name\.android\avd\Pixel_3_API_Q.avd\userdata-qemu.img.qcow2': The process cannot access the file because it is being used by another process.

Then when I try another device I get a pop-up with the following message:

Installation failed with message 'cmd package install-create -r -t -S 1697135' returns error 'Unknown failure: cmd: Can't find service: package'.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!

I've rebooted my machine but I get the same problem each time.

[App] [Ad Free] Sleep Sounds - White noise - Promo Codes

Hi AndroidForums,


Today I present you my second application.

This is a white noise application.

AndroidForums.png


What is a white noise? ...

A white noise is a kind of background noise, like a background sound, that will have some people hypnotic properties. This includes sounds of vacuum cleaners, fans, hair dryers, but also natural sounds like a waterfall, waves or rain.

Features :
More than eighty sounds available
Simple and aesthetic design.
Dozens of presets.
Works in the background.
Creating your own mixes.
Timer.
Individually adjustable sounds.
White noise, pink noise, brown noise.
Works 100 % offline.
Ads Free.

Google Play: https://play.google.com/store/apps/details?id=net.binsp.sleepsounds

Please send MP if you want a Premium code

Attachments

  • 3.png
    3.png
    150.5 KB · Views: 173
  • 4.png
    4.png
    171.6 KB · Views: 204
  • 6.png
    6.png
    73 KB · Views: 166

Apps Why is my array empty? didn't I already call it?

Hi guys... I followed a tutorial on posting pictures in my app... So I have been tracking a problem and am not sure what is going on, Could you please tell me or show me, or even point me in the right direction...

the error points to another section but I traced it to an empty array:

so I have an Filepaths class:

Java:
public class FilePaths {

    //"storage/emulated/0"
    public String ROOT_DIR = Environment.getExternalStorageDirectory().getPath();

    public String PICTURES = ROOT_DIR + "/Pictures";
    public String CAMERA = ROOT_DIR + "/DCIM/camera";

    public String FIREBASE_IMAGE_STORAGE = "photos/users/";

}


in another Class I call am getting my file directories and file paths:

Code:
/**
* Search a directory and return a list of all **directories** contained inside
* @param directory
* @return
*/
public static ArrayList<String> getDirectoryPaths(String directory){
    ArrayList<String> pathArray = new ArrayList<>();
    File file = new File(directory);
    File[] listfiles = file.listFiles();
    for(int i = 0; i < listfiles.length; i++){
        if(listfiles[i].isDirectory()){
            pathArray.add(listfiles[i].getAbsolutePath());
        }
    }
    return pathArray;
}
/**
     * Search a directory and return a list of all **files** contained inside
     * @param directory
     * @return
     */
    public static ArrayList<String> getFilePaths(String directory){
        ArrayList<String> pathArray = new ArrayList<>();
        File file = new File(directory);
 
        File[] listfiles = file.listFiles();
        Log.d(TAG, "getFilePaths: in file search");
 
        if(listfiles != null){
            for(int i = 0; i < listfiles.length; i++) {
                if (listfiles[i].isFile()) {//the error traces back here where it is telling me the listfiles are empty??
                    pathArray.add(listfiles[i].getAbsolutePath());
                } else {
                    Log.d(TAG, "getFilePaths: listfiles array is equal to null");
                }
            }
        }
        return pathArray;
    }

Could anyone please tell me why
listfiles
are empty???

Apps Getting a NullPointerException: boolean...on a null object reference

Dear Community,

finally found a promising forum for android. I apologize, if I post this one here wrong. My problem is, that I am getting a
com.example.networkusercommunication, PID: 20662 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at com.example.networkusercommunication.ChatActivity$5.onDataChange(ChatActivity.java:248)

I am also watching a tutorial to learn. When I implemented a "Delete your message in chat" function. The tutorial showed two versions. One, where you delete the message without leaving a text behind and second, where you leave a "Message deleted" text. I ran two tests with each version seperately, because of the tutorial ), they worked fine ) I liked the second version, so I've deleted the code for the first version ( only one line and the code just deletes message instead of replacing it ) but when I access the Chat Window/Layout it crashes, yesterday it worked fine. In the ChatActivity the "getReceiver" may produce a NullPointerException, it says. I really need help, because I cannot solve it.


Java:
package com.example.networkusercommunication;

import android.content.Intent;
import android.provider.ContactsContract;
import android.service.autofill.Dataset;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.format.DateFormat;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.networkusercommunication.adapter.AdapterChat;
import com.example.networkusercommunication.models.ModelChat;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

public class ChatActivity extends AppCompatActivity {

    // views from xml
    Toolbar toolbar;
    RecyclerView recyclerView;
    ImageView profileIv;
    TextView nameTv, userStatusTv;
    EditText messageEt;
    ImageButton sendBtn;

    //firebase auth
    FirebaseAuth firebaseAuth;

    FirebaseDatabase firebaseDatabase;
    DatabaseReference usersDbRef;

    // for checking if user has seen message or not
    ValueEventListener seenListener;
    DatabaseReference userRefForSeen;

    List<ModelChat> chatList;
    AdapterChat adapterChat;

    String hisUid;
    String myUid;
    String hisImage;


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

        // init views
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setTitle("");
        recyclerView = findViewById(R.id.chat_recyclerView);
        profileIv = findViewById(R.id.profileIv);
        nameTv = findViewById(R.id.nameTv);
        userStatusTv = findViewById(R.id.userStatusTv);
        messageEt = findViewById(R.id.messageEt);
        sendBtn = findViewById(R.id.sendBtn);

        // Layout ( LinearLayout ) for RecyclerView
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setStackFromEnd(true);

        // recyclerview properties
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(linearLayoutManager);

        /* On clicking user from users list we have passed that user's UID using intent. So get that uid here to get the profile picture,
         * name and start chat with user */

        Intent intent = getIntent();
        hisUid = intent.getStringExtra("hisUid");

        // firebase auth instance
        firebaseAuth = FirebaseAuth.getInstance();

        firebaseDatabase = FirebaseDatabase.getInstance();
        usersDbRef = firebaseDatabase.getReference("Users");

        // search user to get that user's info
        Query userQuery = usersDbRef.orderByChild("uid").equalTo(hisUid);

        // get user picture and name
        userQuery.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                // check until required info is received
                for (DataSnapshot ds : dataSnapshot.getChildren()) {
                    // get data
                    String name = "" + ds.child("name").getValue();
                    hisImage = "" + ds.child("image").getValue();
                    String typingStatus = "" + ds.child("typingTo").getValue();

                    // check typing status
                    if (typingStatus.equals(myUid)) {
                        userStatusTv.setText("schreibt...");
                    } else {

                        // get value of onlineStatus
                        String onlineStatus = "" + ds.child("onlineStatus").getValue();
                        if (onlineStatus.equals("online")) {
                            userStatusTv.setText(onlineStatus);
                        } else {
                            // convert timestamp to proper time date
                            // convert time stamp to dd/mm/yyyy hh:mm am/pm
                            // Es gibt verschiedene Zeitstellungen ( auch Deutschland bzw. restliche Welt )
                            Calendar cal = Calendar.getInstance(Locale.ENGLISH);
                            cal.setTimeInMillis(Long.parseLong(onlineStatus));
                            String dateTime = DateFormat.format("dd/MM/yyyy hh:mm aa", cal).toString();
                            userStatusTv.setText("Zuletzt online um: " + dateTime);
                        }

                    }

                    // set data
                    nameTv.setText(name);

                    try {
                        // image received, set it to imageview in toolbar
                        Picasso.get().load(hisImage).placeholder(R.drawable.ic_default_img_white).into(profileIv);

                    } catch (Exception e) {
                        // there is exception getting picture, set default picture
                        Picasso.get().load(R.drawable.ic_default_img_white).into(profileIv);

                    }

                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });

        // click button to send message
        sendBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // get text from edit text
                String message = messageEt.getText().toString().trim();

                // check if text is empty or not
                if (TextUtils.isEmpty(message)) {
                    // text empty
                    Toast.makeText(ChatActivity.this, "Leere Nachricht kann nicht versenden werden", Toast.LENGTH_SHORT).show();

                } else {
                    // text not empty
                    sendMessage(message);

                }

            }
        });

        // check edit text change listener
        messageEt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (s.toString().trim().length() == 0 ) {
                    checkTypingStatus("noOne");
                } else {
                    checkTypingStatus(hisUid); // uid of receiver
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        readMessages();

        seenMessage();

    }

    private void seenMessage() {
        userRefForSeen = FirebaseDatabase.getInstance().getReference("Chats");
        seenListener = userRefForSeen.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for (DataSnapshot ds : dataSnapshot.getChildren()) {
                    ModelChat chat = ds.getValue(ModelChat.class);

                    if ( chat.getReceiver().equals(myUid) && chat.getSender().equals(hisUid)) {

                        HashMap<String, Object> hasSeenHashMap = new HashMap<>();
                        hasSeenHashMap.put("isSeen", true);
                        ds.getRef().updateChildren(hasSeenHashMap);
                    }
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });
    }

    private void readMessages() {
        chatList = new ArrayList<>();
        DatabaseReference dbRef = FirebaseDatabase.getInstance().getReference("Chats");
        dbRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                chatList.clear();
                for (DataSnapshot ds : dataSnapshot.getChildren()) {
                    ModelChat chat = ds.getValue(ModelChat.class);
                    if (chat.getReceiver().equals(myUid) ||
                            (chat.getReceiver().equals(hisUid) && chat.getSender().equals(myUid))) {
                        chatList.add(chat);
                    }

                    // adapter
                    adapterChat = new AdapterChat(ChatActivity.this, chatList, hisImage);
                    adapterChat.notifyDataSetChanged();

                    // set adapter to recyclerview
                    recyclerView.setAdapter(adapterChat);
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });
    }

    private void sendMessage(String message) {

        /* "Chats" node will be created, that will contain all chats. Whenever user
         * sends message it will create a new child in "Chats" node and that child
         * will contain the following key values.
         * sender: UID of sender
         * receiver: UID of receiver
         * message: the actual message
         */

        DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();

        String timestamp = String.valueOf(System.currentTimeMillis());

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("sender", myUid);
        hashMap.put("receiver", hisUid);
        hashMap.put("message", message);
        hashMap.put("timestamp", timestamp);
        hashMap.put("isSeen", false);
        databaseReference.child("Chats").push().setValue(hashMap);

        // reset edittext after sending message
        messageEt.setText("");


    }

    private void checkUserStatus() {

        // get current user
        FirebaseUser user = firebaseAuth.getCurrentUser();
        if (user != null) {
            // user is signed in stay here
            //set email of logged in user
            //mProfileTv.setText(user.getEmail());
            myUid = user.getUid(); // currently signed in user's uid

        } else {
            // user not signed in, go to main activity
            startActivity(new Intent(this, MainActivity.class));
            finish();
        }
    }

    private void checkOnlineStatus(String status) {
        DatabaseReference dbRef = FirebaseDatabase.getInstance().getReference("Users").child(myUid);
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("onlineStatus", status);

        // update value of onlineStatus of current user
        dbRef.updateChildren(hashMap);
    }

    private void checkTypingStatus(String typing) {
        DatabaseReference dbRef = FirebaseDatabase.getInstance().getReference("Users").child(myUid);
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("typingTo", typing);

        // update value of onlineStatus of current user
        dbRef.updateChildren(hashMap);
    }

    @Override
    protected void onStart() {
        checkUserStatus();

        // set online
        checkOnlineStatus("online");
        super.onStart();
    }

    @Override
    protected void onPause() {
        super.onPause();
        // get timestamp
        String timestamp = String.valueOf(System.currentTimeMillis());
        // set offline with last seen time stamp
        checkOnlineStatus(timestamp);
        checkTypingStatus("noOne");
        userRefForSeen.removeEventListener(seenListener);
    }

    @Override
    protected void onResume() {

        // set online
        checkOnlineStatus("online");
        super.onResume();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        // hide searchview, as we don't need it here
        menu.findItem(R.id.action_search).setVisible(false);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_logout) {
            firebaseAuth.signOut();
            checkUserStatus();
        }

        return super.onOptionsItemSelected(item);
    }
}

Java:
package com.example.networkusercommunication.models;

public class ModelChat {

    String message, receiver, sender, timestamp;
    boolean isSeen;

    public ModelChat() {
    }

    public ModelChat(String message, String receiver, String sender, String timestamp, boolean isSeen) {
        this.message = message;
        this.receiver = receiver;
        this.sender = sender;
        this.timestamp = timestamp;
        this.isSeen = isSeen;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public boolean isSeen() {
        return isSeen;
    }

    public void setSeen(boolean seen) {
        isSeen = seen;
    }
}

Java:
package com.example.networkusercommunication.adapter;

import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.networkusercommunication.R;
import com.example.networkusercommunication.models.ModelChat;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.squareup.picasso.Picasso;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

public class AdapterChat extends RecyclerView.Adapter<AdapterChat.MyHolder> {

    private static final int MSG_TYPE_LEFT = 0;
    private static final int MSG_TYPE_RIGHT = 1;
    Context context;
    List<ModelChat> chatList;
    String imageUrl;

    FirebaseUser fUser;

    public AdapterChat(Context context, List<ModelChat> chatList, String imageUrl) {
        this.context = context;
        this.chatList = chatList;
        this.imageUrl = imageUrl;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        // inflate layouts: row_chat_left.xml for receiver, row_chat_right.xml for sender
        if (i == MSG_TYPE_RIGHT) {
            View view = LayoutInflater.from(context).inflate(R.layout.row_chat_right, viewGroup, false);
            return new MyHolder(view);
        } else {
            View view = LayoutInflater.from(context).inflate(R.layout.row_chat_left, viewGroup, false);
            return new MyHolder(view);
        }

    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder myHolder, final int i) {

        // get data
        String message = chatList.get(i).getMessage();
        String timeStamp = chatList.get(i).getTimestamp();

        // convert time stamp to dd/mm/yyyy hh:mm am/pm
        // Es gibt verschiedene Zeitstellungen ( auch Deutschland bzw. restliche Welt )
        Calendar cal = Calendar.getInstance(Locale.ENGLISH);
        cal.setTimeInMillis(Long.parseLong(timeStamp));
        String dateTime = DateFormat.format("dd/MM/yyyy hh:mm aa", cal).toString();

        // set data
        myHolder.messageTv.setText(message);
        myHolder.timeTv.setText(dateTime);
        try {
            Picasso.get().load(imageUrl).into(myHolder.profileIv);
        } catch (Exception e) {

        }

        // click to show delete dialog
        myHolder.messageLAyout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // show delete message confirm dialog
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle("Delete");
                builder.setMessage("Are you sure to delete this message?");
                // delete button
                builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        deleteMessage(i);
                    }
                });

                // cancel delete button
                builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // dismiss dialog
                        dialog.dismiss();
                    }
                });

                // create and show dialog
                builder.create().show();
            }
        });

        // set seen/delivered status of message
        if (i == chatList.size() - 1) {
            if (chatList.get(i).isSeen()) {
                myHolder.isSeenTv.setText("Gesehen");
            } else {
                myHolder.isSeenTv.setText("Versendet");
            }
        } else {
            myHolder.isSeenTv.setVisibility(View.GONE);
        }
    }

    private void deleteMessage(int position) {

        final FirebaseUser myUID = FirebaseAuth.getInstance().getCurrentUser();

        String msgTimeStamp = chatList.get(position).getTimestamp();
        DatabaseReference dbRef = FirebaseDatabase.getInstance().getReference("Chats");
        Query query = dbRef.orderByChild("timestamp").equalTo(msgTimeStamp);
        query.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for (DataSnapshot ds:dataSnapshot.getChildren()) {

                    if (ds.child("sender").getValue().equals(myUID)) {

                        // Set value of message in "This message was deleted"
                        HashMap<String, Object > hashMap = new HashMap<>();
                        hashMap.put("message", "This message was deleted");
                        ds.getRef().updateChildren(hashMap);

                        Toast.makeText(context, "message deleted", Toast.LENGTH_SHORT).show();

                    } else  {
                        Toast.makeText(context, "Only your messages can be deleted", Toast.LENGTH_SHORT).show();
                    }

                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });




    }


    @Override
    public int getItemCount() {
        return chatList.size();
    }

    @Override
    public int getItemViewType(int position) {
        // get currently signed in user
        fUser = FirebaseAuth.getInstance().getCurrentUser();
        if (chatList.get(position).getSender().equals(fUser.getUid())) {
            return MSG_TYPE_RIGHT;
        } else {
            return MSG_TYPE_LEFT;
        }
    }

    // view holder class
    class MyHolder extends RecyclerView.ViewHolder {

        // views
        ImageView profileIv;
        TextView messageTv, timeTv, isSeenTv;
        LinearLayout messageLAyout; // for click listener to show delete


        public MyHolder(@NonNull View itemView) {
            super(itemView);

            // init views
            profileIv = itemView.findViewById(R.id.profileIv);
            messageTv = itemView.findViewById(R.id.messageTv);
            timeTv = itemView.findViewById(R.id.timeTv);
            isSeenTv = itemView.findViewById(R.id.isSeenTv);
            messageLAyout = itemView.findViewById(R.id.messageLayout);


        }
    }
}

Filter

Back
Top Bottom