PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label emulation. Show all posts
Showing posts with label emulation. Show all posts

Monday, November 7, 2022

[FIXED] how to get option menu on android api level 12 emulator?

 November 07, 2022     android, emulation, menu, optionmenu     No comments   

Issue

I am new to work with android tablet api level 12. I have created 7 inches avd with 1024*600 screen resolution. I have implemented sample application for get the option menus on my screen and back button. I am unable to see option button and back button on my emulator.

I have implemented for option menu code as follows:

  @Override
 public boolean onCreateOptionsMenu(Menu menu) {
     MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.menu.menu, menu);

     return true;
 }


 @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
    case R.id.icon:     Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
                        break;
    case R.id.text:     Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
                        break;
    case R.id.icontext: Toast.makeText(this, "You pressed the icon and text!", Toast.LENGTH_LONG).show();
                        break;
    }

    return true;
}

Solution

You can use keyboard shortcuts to simulate the hardware buttons. There's a table of the shortcuts here. The Back button is simulated by pressing escape, and the menu button is simulated by the Page-Up or F2 keys.



Answered By - Ted Hopp
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, October 18, 2022

[FIXED] Why can macos(x86) run docker arm container arm64v8/alpine?

 October 18, 2022     docker, emulation, linux-kernel, qemu     No comments   

Issue

I happened to find that my macos(x86) can run a docker container for an arm image arm64v8/alpine, but with the following warning:

docker run -it  arm64v8/alpine uname -a

WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and no specific platform was requested
Linux d5509c57dd24 4.19.121-linuxkit #1 SMP Tue Dec 1 17:50:32 UTC 2020 aarch64 Linux

And I'm pretty sure the image is not a multi-arch image (docker manifest inspect --verbose arm64v8/alpine). Why can x86 run an arm container?


Solution

You are correct, the image is not multi architecture, yet, docker can run it. Reason behind this is a kernel subsystem called binfmt_misc which allows to set the magic numbers of a binary file to specific actions for their execution. You can read more in this nice wikipedia post about it.

Docker for Mac is arriving prepared for the binfmt magic, so there is nothing to be done to enable it. It will be enabled out-of-box with the installation, all you need to do is to fetch the image and run. The details of the mechanism can be found in repository of docker-for-mac project on this link.

To explain it simply, the binary images have the magic number that allows the kernel to decide how to handle the execution. When binfmt_misc intercepts a file for which it recognizes the magic numbers it will invoke the handler that is associated with the magic numbers.

This alone is not enough to run the container. The next part of the magic is QEMU which is the emulator for various CPU architectures. The kernel (binfmt_misc) will invoke the quemy for each of the binaries that are ARM64 and will emulate the ARM64v8.

This is not limited to docker nor to the virtual machine that is running the docker on macOS. Any linux system can be configured to do this.

You can use following to install it setup Ubuntu to run the emulation.

sudo apt-get install qemu binfmt-support qemu-user-static # Install the qemu packages
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes # This step will execute the registering scripts

docker run --rm -t arm64v8/ubuntu uname -m # Testing the emulation environment

More details about the whole process of the set-up can be found in the qemu-user-static repository

OP: If you are wondering what is the usefulness of this, from my personal experiance, I am using this functionality heavily when porting applications from X86 to other architectures (mainly ARM64). This allows me to run build systems for various architectures without having a physical machine on which I can run the build.



Answered By - jordanvrtanoski
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, April 21, 2022

[FIXED] How do you connect your terminal with the Android emulator

 April 21, 2022     android, connection, emulation, terminal     No comments   

Issue

I have tried the navigate to the android tool folder and entering the "adb shell" command but it doesn't seem to work. My terminal seems only to recognize the adb part of the command and gives me an error message. What am I doing wrong???


Solution

  1. List all connected devices by typing adb devices

Check, if there are any devices listed. If not you may want to check that your device is connected and/or your emulator is running.

  1. If it works and you have for example your emulator running and your usb-device connected use:
  • adb shell if you only have device connected.

  • adb -d shell to connect to an USB-Device.

  • adb -e shell to connect to an emulated device.

If you have more than one emulator or usb devices you might want to use: adb -s <DEVICE> shell

Note: Make sure that the path to the android-sdk is properly set-up in your environment. To quickcheck, fire up a shell and type adb version. If that command succeeds, you're set up. If not, add /path/to/android-sdk/tools and /path/to/android/platform-tools to your $PATH env variable. On windows the android sdk is typically located in C:\Users\<username>\AppData\Local\Android\sdk.



Answered By - Darokthar
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing