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

How to find the size of an object in Java Android

I'm a newbie in android and python, and I'm trying to establish a TCP socket connection between my android client and a python server. Every time I swipe in my app, I send the swipe movement's direction to the server.

Java:
//java client
           OutputStream output = client.getOutputStream();
           DataOutputStream out = new DataOutputStream(new BufferedOutputStream(output));

           byte[] msg;
           if(strings[1].equals("swipe"))
           {
               out.write(strings[1].getBytes());
               out.flush();
               //strings[0] contains the movement information in format of:
               //xmovement_ymovement
               //for example: 2.5365_8.5478
               msg = strings[0].getBytes();
               out.write(msg);
               out.flush();
           }

Code:
#python server
   #the 1024 is a temporary number I just put in there
   #because I don't know how to find the size of the data in the java client side
   request_byte = client_socket.recv(1024)
   print("reqeust_byte size: " + str(sys.getsizeof(request_byte)))
   request = request_byte.decode()
   print("Received " + request)

   if request == "swipe":
       movement_byte = client_socket.recv(1024)
       print("movement_byte size: " + str(sys.getsizeof(movement_byte)))
       movement_str = movement_byte.decode()
       x_movement, y_movement = movement_str.split("_")
       print("x: " + x_movement)
       print("y: " + y_movement)
       swipe(float(x_movement), float(y_movement))


When a simple button press is done and a single data is sent, the code works fine, but when I swipe and a lot of data is being sent in a short amount of time to the server, the data gets mixed up and turns unpredictable.

Now, as this post https://stackoverflow.com/questions/26641840/receiving-end-of-socket-splits-data-when-printed says, I know that I need to build a protocol that delineates messages, but on the Java client side, I can't get the size of the data I'm trying to send, so I'm stuck here.

This post https://stackoverflow.com/questions...-way-to-determine-the-size-of-an-object#52682 says I can find size of objects by using java.lang.instrument package, but I can't import java.lang.instrument.Instrumentation in android studio. Is there another way to find the size of an object in android studio?

  • Poll Poll
How to turn your Samsung GALAXY Note10/10+ into a fully fleged console!

Rate this Guide!

  • Votes: 1 33.3%
  • ⭐⭐

    Votes: 0 0.0%
  • ⭐⭐⭐

    Votes: 0 0.0%
  • ⭐⭐⭐⭐

    Votes: 0 0.0%
  • ⭐⭐⭐⭐⭐

    Votes: 2 66.7%

Today I have the solution to build the ultimate mobile console experience and before we get started here is what you will need:

Requirements:

• Android Gamepad (No PlayStation & Xbox etc Controllers as they do not work correctly with the Note 10/10+).

• Samsung GALAXY Note10/10+.

• Google Chromecast.

• USB Type-C Cable.

• Micro USB Cable (For Chromecast).

• HDTV (Supporting 1080p or Higher).

• High Speed Internet Connection (Wi-Fi).

Now that you got what is required here's how it works

Your Samsung GALAXY Note 10/10+ will be your host device this is the hardware your games will be stored on. This is where your accessories will be connected to.

To setup your Note10/10+ you will need to setup your Chromecast first.

Step 1: Connect your Chromecast to you HDTV and set it up (you may need to download the Google Home app to setup the Chromecast if you haven't already).

Step 2: Now the Chromecast will boot up, once it finishes booting up you will need to connect your game pad to your Note10/10+ via Bluetooth (if you need a gamepad controller look at bottom of the thread for links to our recommended gamepads).

Step 3: Once you connected your gamepad controller connect your Note10/10+ to your Chromecast to connect swipe your notifications down till you see all your Quicktiles and swipe to the right till you see a QS called "Smart View" once you selected it you will start searching for the Chromecast, once it has found your Chromecast select it it will connect to it and your screen will be mirrored.

Step 4: Now once your connected take your USB Type-C and plug it in your Note10/10+ so if your planning to play for more then 1hour it does not die on you while your in the middle of an important game session. (For the Micro USB was for your Chromecast to supply power and we didn't need to explain that).

Step 5: Now not all games will support any kind of gamepads and your basically trialling and erroring each game but if an app that does support gamepads such as for example: Dolphin Emulator & PPSSPP you will need to configure the games you want to play manually as it does not do it automatically.

Once your got the controller setup and other things setup as well your ready to start playing your favorite games!

Internet Connection Notice: This does require an internet connection and may vary depending on your speeds, the faster your connection speed is the faster and better the games will be streamed to your Chromecast!

Buy an Android Gamepad: https://ebay.us/FwYdZ8

Help How to opt out the Designed for Families program of Google Play?

Hi,

I have a free app available on Google Play. I got an email from Google Play after I submitted the 'Target audience and content' for this app on 'App content' page of Play Console today. It said that my app does not meet their eligibility criteria for the Designed for Families program.

As my app is designed for everyone, I decide not to participate in the Designed for Families program for the app. But I failed to find any options to allow me to opt out the Designed for Families program.

Sign in to my Play Console.
Select my app.
On the left menu, click Store presence > Pricing & distribution.

But in the 'User programs' section, I couldn't find the "Designed for Families".
There are only 'Managed Google Play' and 'Daydream'.

Why is not there a checkbox about "Designed for Families" for me to uncheck?

Thank you in advance.

Play the 4K Video in video tag inside the WebView

In our Application, We are using Exoplayer and Webview in the Same Screen. We are loading some HTML content in the Webview and 4K Video in the Exoplayer. Playing the 4KVideo in exoplayer and HTML Content loading in the webview playing fine. Sometimes we are hiding the exoplayer and playing the 4K video in the WebView by loading the HTML content inside the iframe of the HTML. sometimes it was not play the video in the video tag.just showing up the video tag and show the HTML Content alone.

Verizon may sell OnePlus phones

It now looks like OnePlus are going the way of Samsung, et al, and following T-Mobile (USA) and Sprint, they are about to do a similar carrier model deal with Verizon (USA)...

Verizon may sell OnePlus phones next year, possibly the OnePlus 7T Pro 5G McLaren Edition

This will most likely be a single sim model as per the other 2 versions and will probably offer a carrier locked and ersatz version, of the global OnePlus' firmware with the usual carrier slow or no, updates.

Bottom line... "If you want the full, unfettered, OnePlus phone experience... pay the full price and get yourself the Global model." ;)

Emulator Problem

For a month now I've not been able to get a proper function from my emulator. Here's a group of error messages I get today in the Event log:

I would have removed this thread since I moved it to App Development but I don't see a link to remove it from this area.


Code:
9/17/2019
6:03 AM    * daemon not running; starting now at tcp:5037

6:03 AM    * daemon started successfully

6:03 AM    Gradle sync started with single-variant sync

6:03 AM    Project setup started

6:03 AM    Gradle sync finished in 3 s 989 ms (from cached state)

6:04 AM    Executing tasks: [:app:generateDebugSources] in project C:\Users\Shelby\AndroidStudioProjects\JavaArrays

6:04 AM    NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN

6:04 AM    Gradle build finished in 30 s 252 ms

6:08 AM    Executing tasks: [:app:assembleDebug] in project C:\Users\Shelby\AndroidStudioProjects\JavaArrays

6:08 AM    Emulator: dsound: Could not initialize DirectSoundCapture

6:08 AM    Emulator: dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: audio: Failed to create voice `goldfish_audio_in'

6:08 AM    Emulator: C:\Users\Shelby\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: warning: opening audio input failed

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: audio: Failed to create voice `adc'

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: dsound: Attempt to initialize voice without DirectSoundCapture object

6:08 AM    Emulator: audio: Failed to create voice `adc'

6:09 AM    Gradle build finished in 17 s 347 ms

6:09 AM    Install successfully finished in 566 ms.: App restart successful without requiring a re-install.

6:09 AM    Executing tasks: [:app:assembleDebug] in project C:\Users\Shelby\AndroidStudioProjects\JavaArrays

6:09 AM    Gradle build finished in 3 s 339 ms

6:09 AM    Install successfully finished in 667 ms.: App restart successful without requiring a re-install.

Here's the entire project which I am building from an android classroom from udemy.com by my instructor .

Code:
package com.swayzeconstruction.javaarrays;

public class Main {
    public static void main(String[] args) {
        String[] names = new String[5];
        names[0] = "Shelby";
        names[1] = "Jaam";
        names[2] = "Bisous";
        names[3] = "Felix";
        names[4] = "Hadi";

        System.out.println(names[3]);
        int[] numbers = new int[5];  //apparently gives all values of array
        //or the following
    }

    {
        String[] names2 = new String[5];
        System.out.println(names2[2]);  //gives second value of array
        // or the following
    }

    {
        String[] names3 = new String[5];
        {
            System.out.println(names3[2]);
            int[] numbers = {1, 2, 3, 4, 5};  //note: using curly braces
            System.out.println(numbers[1]);   // to get second element
        }

    }
}

Any ideas? Thanks

Instagram - Retrofit

Hello friends,
The following url returns the user's followers as json if the user logged in to instagram in the browser. If no input is made, the data is not returned.
How do I set a user's login status when sending a request to this url with Retrofit on Android? I think this url will return empty data again if no login is made.

Example
https://www.instagram.com/graphql/query/?query_id=17874545323001329&id=427553890&first=20

System doesn't unmute notifications

When I mute using the hot key in the tray, all options go to mute. However, when I deselect same button and return soind, media & calls return to same level as before however the notifications option stays mutted. It didn't always do this but it's been going on for at least a few months. I'm up to date on system updates. Android 9 Kernal 4.4.153 July 31.

Any known fixes?

Root Format Write-protected Encrypred SD card

I used a 64GB SanDisk SD card in Lenovo K4 Note as internal storage. After the phone got reset, I realized the SD card is still encrypted. I retrieved data using Linux recovery tools. After retrieving the data, I am trying to format the SD card but I am getting Read-write error on Fedora and Cyclic Redudancy Check on Windows. I am sure that the SD card is write-protected and I am able to read the data. Is there any Android tool that I can use to flash the SD card and make it reusable. I am okay to explore to fix even the cylinders and sectors of the SD card.

Higher FPS drains battery faster and heats faster?

Hello people. I just want to confirm. If a heavy game set in highest settings that gives 60+ FPS, would that drain battery faster than lower FPS?
then does that mean flagships drain battery faster than midrange in max settings heavy gaming?
And does steady 60 FPS in flagship heats faster than midrange too?
I read that when playing a heavy game in max settings on midrange phones, it will drop below 60 fps, what is the lowest FPS that you will notice that does not look like 60 fps smooth? Is it 30? Thank you!

Help Android remote support API follows the NIST 800-80 guidelines?

Does android remote support API follows the NIST 800-80 guidelines on device wipe operation ? if yes it falls under "clear" or "purge" operations

Below APi used to wipe device
https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#wipeData(int)

NIST 800-80 Guide
https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-88r1.pdf

Tech Dummie...101

I would like some options about changing my backgrounds and keyboards without messing up the system...NO LAUNCHER however I am now terrified of what I can install or dowload.. I had a few questions I had already put out there...one being confusing about my phone being HACKED it was google fixed it!!! anyways...I want to learn every thing i can now about technology... Tech Dummie thats me and I'm not ashamed so help me out...


Tech Dummie
Samsung Galaxy Edge 7s...Android pie 9

Android 9 Microphone feedback

My wife just got a new Galaxy S9. I noticed that it was significantly harder to hear her when we were talking. After a lot of troubleshooting, I've believe the problem is that her microphone is picking up the sounds coming from her speakers and canceling out all noises from being recorded. This happens when she has me on speaker phone as well as while we are in a video chat with Duo, Hangout, Skype, or Messenger (like I said, a lot of troubleshooting lol).

Is there a way to adjust the noise reduction or ambient noise threshold in Android 9?

Thank you in advance!

Help How to RE-fix volume level on FiiO M7

I don't know much of anything about Android systems, so I'm hoping someone can help me here. I use a FiiO M7 as my main music player, and primarily I use my AirPods with it. When I first paired them, I noticed the volume level was very low, even at the maximum setting. After some googling, I enabled developer options, and set the Disable Absolute Volume setting to ON. That fixed the problem, and it's been fine until about a week ago, when it suddenly reverted back to the quieter volume levels. It might worth mentioning that I regularly switch the AirPods between my iPhone and the FiiO, but again, until now this has gone without issue.

I've now unpaired, forgotten, re-paired, restarted the device, switched that setting off and on several times (and all of these in every possible order), and done a complete factory reset, and the low volume persists. I'm wondering what else I could try to get this fixed.

I've read that the Android OS this device runs on is a very pared down version: it says

Kernel version 3.18.14-user-g3a4465b-dirty
FiiO@asc #112
Build number 1.0.2

Is there something I'm missing here?Is there a VERY specific order I need to be following these steps in that I'm somehow failing?

Filter

Back
Top Bottom