How do you generate a java class from an activity xml? - Android Studio

I have created a screen layout and now I want to generate a java class that is linked to it.
I am familiar with how to do this in Visual Studio C++ with the 'Class Wizard' and I understand how my dialog resource is linked to the class wizard generated class via the IDD = IDD_DIALOG_MYDIALOG.
But I don't yet understand how to do this with android studio.
Can anyone enlighten me please.

I am not sure if you can do it by wizard in Android Studio.
Howewer, you can create both layout and Java class by using New -> Activity -> Blank Activity from context menu in your package. So I think that one option would be to use this wizard, and then copy your layout to created .xml file.
You can also manually create Java class extending Activity and link it by using setContentView(R.layout.your_layout) in onCreate() method.

Related

maps to SDCARD found on microsoft.com a intersting xml code file any ideas how use?

Hi Im having a htc windows phone 8s with windows phone 8.1 think (gdr1) and unlocked it to get accsess to the phone via windows phone power tools 2.8.3 . Is this "real rooted" or not?
Im searching for a solution to get maps to sdcards ...
Im finding two things
first the lumia storage check
and that you can change the regestry . But the tools sawapu are for samsung phones only and a regestry editor can't edit the regestry of dwords ..
I have found follow interesstings maybe can anyone make a xap out of this??
the code i found on follow adress
https://dev.windowsphone.com/en-US/OEM/docs/Customization/Map_data_on_an_SD_card_and_map_preload (of juli)
there is followed i found:
Map data on an SD card and map preload
Customization and runtime configuration > Customizations for maps
July 22, 2014
Applies to: Windows Phone hardware development
Map data is used by the Maps application and the map control for third-party applications. OEMs can choose to store this data on an SD card, which provides the advantage of saving internal memory space for user data and allows the user to download more offline map data. Microsoft recommends enabling the UseExternalStorage setting on phones with less than 8 GB of user storage and has an SD card slot.
UseExternalStorage can be used whether or not an SD card with preloaded map data is included on the phone. If no SD card is present, the system uses internal storage until an SD card is available and then automatically switches to using an SD card for map storage. The user's ability to download map regions is disabled until an SD card is available.
Important note
SD card performance can affect the quality of the Maps experience when maps are stored on the SD card. When an SD card is used, Microsoft recommends that OEMs test the Maps experience and the speed of map downloads with the specific SD card part that will be used on retail phones to determine if performance is satisfactory.
Sample: UseExternalStorage
Use the customization samples
Constraints: None
Instructions:
Microsoft recommends enabling UseExternalStorage on phones with less than 8 GB of user storage and has an SD card slot.
Create a customization answer file using the contents shown in the following code sample or use the sample UseExternalStorage.xml file.
Copy code
<?xml version="1.0" encoding="utf-8" ?>
<ImageCustomizations xmlns="http://schemas.microsoft.com/embedded/2004/10/ImageUpdate"
Name="PreloadedMapData"
Description="Use to preload map data on an SD card."
Owner=""
OwnerType="OEM">
<Static>
<!-- Enable external storage for map data on an SD card -->
<Settings Path="Maps/Storage">
<Setting Name="UseExternalStorage" Value="" />
</Settings>
</Static>
</ImageCustomizations>
Specify an Owner.
Set the Value to one of the following:
Value
Description
0 or No
Do not store map regions on an SD card.
1 or Yes
Store map regions on an SD card.
If including an SD card with the device, add the preloaded map data to the SD card. Unzip the appropriate map variant data package and copy the “diskcache” folder onto the SD card under the d:\MapData directory.
Note
When unzipping the appropriate map variant data package, you must use a file compression/decompression utility that preserves the file attributes and timestamps. If the utility does not preserve this information, the map(s) will be treated as invalid by the OS.
Testing:
Flash a build that contains this customization on a phone.
Launch the Maps application and open Settings from the application bar.
Click on the Download Maps button and verify that the expected region displays under downloaded maps.
Click to expand...
Click to collapse
what says this ? i don't check what we have to do to use this solution.
Informations
to use the *.xml file you need a zip and visual basic 2013???
https://dev.windowsphone.com/en-US/OEM/docs/Customization/Use_the_customization_samples
Use the customization samples
Customization and runtime configuration
July 22, 2014
Applies to: Windows Phone hardware development
Partners can download and use the sample customization answer files to get started with customizing Windows Phone 8.1.
To obtain the sample customization answer files
Download the WPBlue_Customization_Code_Samples.zip file from the Connect site. This .zip contains sample customization answer files for the majority of customizations documented in this section.
For a list of all customization samples, see Customization samples index.
To use the sample customization answer files and build a custom phone image
Ensure that you have an updated kit installation, and that you can build a phone image using it and flash that image to your engineering device.
If you have not already done so, create a folder for your packages in %WPDKCONTENTROOT%. Name the folder OEMCustomizationPackages or give it a similar name so you know this folder contains all your customizations. Note that this folder can include many subfolders.
Copy a sample customization folder from WPBlue_Customization_Code_Samples.zip to the OEMCustomizationPackages folder.
Open the sample XML customization answer file and modify it to optionally change the values from the sample customization answer file and provide any required values:
Note
The values used in the root customization answer file (or the one you specify as the input customization answer file during ImgGen.cmd or CustomizationGen.cmd in Step 6) is used to determine the package owner so it is important to provide these required values.
Name
Description
Owner
OwnerType (in the customization samples this is typically already set to 'OEM').
Any files, assets, or other settings specific to the customization. See the corresponding topic in the Customization and runtime configuration section of the documentation for more information about what to change and how.
You must also update or replace any additional files included in the sample folder. Instructions are provided in the customization topic in the documentation.
Note that you’ll be using the customization answer file as one of the inputs when building your customization package or OS image.
Open a Developer Command Prompt for VS2013 window (if you have installed Visual Studio 2013) or a Command Prompt window (if you have not installed Visual Studio 2013) as an administrator. Configure the environment variables in this window as described in the Set up environment variables section of Preparing for Windows Phone development.
Depending on what you want to do, you can use the customization answer file to create a package containing your customization(s) or use the answer file as one of the inputs to create an OS image.
To use the customization answer file to generate a package without building an OS image, see Generating customization packages without creating an image in Building a phone image using ImgGen.cmd to find out how to use CustomizationGen.cmd.
To build an image as an .ffu file using the customization answer file as one of the inputs, see Using ImgGen.cmd to generate the image in Building a phone image using ImgGen.cmd to find out how to use ImgGen.cmd.
Flash the .ffu file to a phone. For more information, see Use the flashing tools provided by Microsoft.
See the Testing steps section in the corresponding customization topic to verify that the customization has been configured properly.
Click to expand...
Click to collapse
hmmmmm im searching for it this one hmmmm WPBlue_Customization_Code_Samples.zip
maybe we have a solution don't know
ah ok microsoft flashing tool for wp phones maybe interesting but complicated
https://dev.windowsphone.com/en-US/.../Use_the_flashing_tools_provided_by_Microsoft
and you have special drivers hmmmmmmmmmmmmmmmmmmmmmmmmmm very complicated

[Q] Couldn't load private static inner class

I'm trying to load a class with classLoader.loadClass(). This class' package name is "com.android.inputmethod.keyboard.KeyboardView.KeyDrawParams".
It's definied as
Code:
private static class KeyDrawParams
The snippet of code that doesn't works is this
Code:
Class<?> mKeyDrawParams = lpparam.classLoader.loadClass("com.android.inputmethod.keyboard.KeyboardView$KeyDrawParams");
I've tried everything, but it still doesn't work. It seems that the classLoader doesn't find the class in the .dex file. I obtain this log in xposed
Code:
java.lang.ClassNotFoundException: Didn't find class "com.android.inputmethod.keyboard.KeyboardView$KeyDrawParams" on path: DexPathList[[zip file "/system/app/LatinIME.apk"],nativeLibraryDirectories=[/system/lib]]
Is there any problem with private static inner class? I've decompiled the apk of the keyboard with an online tool, because apktool doesn't work on my ubuntu... Do anyone know if there is an error in decompilation? (I don't find the usefulness of declaring a private static (inner) class....)
I decompiled it again. It has a completely different code-structure. I give you an advice: don't trust in online decompiling tool

Cntrl + click not working in Android studio

I am new to Android Studio.I like the IDE very much,it has got some nice set of features and has a rich look and feel, however I have some issues with the IDE. I recently created a Cordova application in android studio.I created an HTML file called index.html under assests/www folder.I included my jquery-1.11.3.min.js inside index.html file.I have the habit of checking whether the file jquery-1.11.3.min.js has been correctly included inside HTML file.In eclipse I use cntrl +click to check whether the js file path given is right.But when I use the same thing in Android studio,even if the path is right,it is showing like 'Cannot find declaration to go to'.Please help me on this.

Issue with the dependent library

I trying to use Gstreamer on Android via Xamarin.Android(in the Visual Studio), so I built this sample project(github.com/jaroslavas/Gstreamer-Android-example) on the Ubuntu, took the compiled libtutorial-5.so and libgstreamer_android.so libraries and added them into the Xamarin.Android project as AndroidNativeLibrary's. When I try to use libgstreamer_android.so using DllImport, then all going ok, but when I try to use libtutorial-5.so (of course using DllImport), then I get:
DllImport unable to load library 'dlopen failed: could not load library "build/obj/local/armeabi-v7a/libgstreamer_android.so" needed by "libtutorial-5.so"; caused by library "build/obj/local/armeabi-v7a/libgstreamer_android.so" not found'.
Click to expand...
Click to collapse
This error occurs because libtutorial-5.so depends on the libgstreamer_android.so. libtutorial-5.so trying to find libgstreamer_android.so library in build/obj/local/armeabi-v7a/libgstreamer_android.so location.
But of course these two libraries are located in the lib/armeabi-v7a directory and even if I replace all two libraries or just libgstreamer_android.so in this location, then I still have this error.
So how can I change path of the library on which my first library will depend in the Android Studio or just in the .mk files(on the .so building stage)?
Hi, lib not found may cause by:
1. Lib is not exist.
2. Lib that declare in Build.gradle that is different that that you load in java class
3. Function name is not follow the form (the dot. in package name of java class is replaced by "_" in c++ function and class.
4. Clean project and rebuilt it. If you not clean, old lib .so will not be deleted.
5. Check if you declare create in android.productFlavors{}

Problem with Java

Hello. I'm new to the forum and to programming aswell. I'm trying to learn how to make an app so I started with a tutorial online, but I'm having a problem. I can't post a link but the tutorial is called "Make Your First Android App: Part 2/3 - Ray Wenderlich". On the section "Accessing Views From Within Java" when I add "android:text= @string/hello_world"" I get an error. On the bottom it says I should be using a @string but when I do the preview window displays the @string/" aswell. What's that about?
Second, I can't rename the string after changing hello_world to something else. Why is the tutorial even saying I should rename it? What will that do?
Lastly, in MainActivity.java above onCreate I have to insert a line of code. The tutorial doesn't explain why I need to do that. Where should the line go, the code is
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wherever I insert the code and press Alt+Enter I mess up the whole thing...
Sorry that these questions are annoying and basic, I just really want to learn to make apps and I'm trying to figure things out alone.
Thanks.
P.S. one more thing, in "Buttons and Listeners" there is a part saying:
"Then there’s text, for which you need to add a line in strings.xml such as the following:
<string name="button">Update The TextView</string>"
when I do that I get an error in strings.xml
If you are having problems related to Java, the following tips should help you getting things working -
» Download and Install Java
» Use Java
» Test Java
» Remove Old Versions of Java
» Find Java.
basic issues
1) all strings you use needs to be defined in string.xml file, by doing so, you separate messages and names from code and it can be re used in your app from single source, easy to maintain.
2)ALT + ENTER is used to resolve import, when you add code and introduce new class, you need to import it.
3)Oncreate method in activity is used to setup layout for activity and provide content to be displayed on screen for the activity

Categories

Resources