This question already has answers here:
Android Studio shows wrong file contents
(10 answers)
Closed 1 year ago.
I am working on a project from last 1 month. One day I wrote the code and closed the android studio. After that when I opened it some code was automatically changed and doesn't maked any sense. Like before, a java code of my activity was looking like this-
but now it is looking like this-
Why did this happened. I was working on this project from very long but many of my hard work is ruined. The code automatically changed to something like null null null... as in the screen shot. this only happened to some of my java activity's. Please if anyone know why this happened and how to fix it please tell me.
check in local history, you will be able to get the recent changes there.
adding steps-
right click on file in which you are facing issue.
click on "local history", it will give option to show history.
attaching screenshot for better understanding.
Related
This question already has answers here:
AppCompatActivity.onCreate can only be called from within the same library group
(3 answers)
Closed 4 years ago.
I use this code
ActionMenuItemView item = (ActionMenuItemView) findViewById(R.id.my_item_id);
item.setTitle("Test String");
and get the error
ActionMenuItemView.setTitle can only be called from within the same library group (groupId=com.android.support)
I use the Android SDK 27 with Java 8 support activated. All related issues I found were bugs in previous releases of older Android versions. But I use the latest one.
The app runs though anyway. But how to get rid of that error without only suppressing it?
this link
helped me out.
It seems that the FloatingActionButton was move to a new package and now uses the .show() and .hide() methods instead of setVisibility().
The post applies to Kotlin, but the method names are the same for Java.
Hope this helps someone out there.
This question already has answers here:
How to get a list of current open windows/process with Java?
(14 answers)
Closed 6 years ago.
I am currently writing a Java Application, that needs to filter the name of the Program whichs UI is front. Sorry for my bad english.
So let's say the Java App is running in Background and I open Windows -> Games -> Minesweeper then i want the App to only tell me "Active: Minesweeper". Without any additional information. Just the name "Minesweeper"
I already tried using JavaNativeAccess but I'm still unfamiliar with it.
Thanks you all in advance
You might want to look at the following link which might be of help:
How to get a list of current open windows/process with Java?
This question already has answers here:
R cannot be resolved - Android error
(108 answers)
Closed 6 years ago.
This has happened on a few different occasions, and I've always just kind of ignored it - but now I'm getting close to being finished with some of my projects, so it can no longer be ignored..
The Issue is as follows: While working on a project in Android Studio, on multiple occasions, seemingly at random, references to "R" will become Red, as if it were an error (or not found)..
For example, in my Main Activity, this reference to R is red, indicating an Error.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Everything with Android Studio is updated via the standard update channel.. The project isn't complicated whatsoever, and I haven't messed with anything that could be delicate, or somehow affect R.. so I'm left extremely confused..
Can anybody offer any kind of explanation regarding this issue?
I would greatly appreciate any advice I can get :) Thanks!
UPDATE: ALTHOUGH THE "DUPLICATE" I WAS LINKED TO BELOW (WHICH I READ FOR ABOUT AN HOUR) DID IN FACT CONTAIN SOME GOOD INFORMATION, IT WAS HOWEVER, A CONVERSATION THAT SEEMED TO CIRCULATE AROUND ECLIPSE (RATHER THAN ANDROID STUDIO, WHICH COULD DRASTICALLY CHANGE THINGS IN SOME CASES). THAT SAID, I DID FINALLY SUCCESSFULLY FIX THE CAUSE OF THE ISSUE! THIS PARTICULAR CASE WASN'T DIRECTLY REFERENCED IN THE LINK I WAS GIVEN, ALTHOUGH I DID GATHER ENOUGH FROM IT TO KNOW GENERALLY WHERE TO SNOOP AROUND FOR THE ERROR. SURE ENOUGH, IT WAS ACTUALLY A MANIFEST FILE REFERENCE TO THE APP ICON (LOL) SOMEHOW IT WAS MESSING THINGS UP, AND SO IN THE
<APPLICATION> SECTION OF THE MANIFEST FILE, I SIMPLY HAD TO ADD:
tools:replace="android:icon"
AFTER THAT, I WENT TO THE MENU AND DID A REBUILD, AND FINALLY IT BUILT THE PROJECT SUCCESSFULLY WITHOUT ANY ERRORS! HOPEFULLY THIS HELPS SOMEBODY ELSE OUT THERE WITH THE SAME ISSUE!
..FOR THOSE OF YOU WHO WANT THE SHORT VERSION OF WHAT I READ IN THE LINK: IN GENERAL, THE "R" NOT FOUND ISSUE SEEMS TO BE CAUSED MOSTLY BY ERRORS OR MISTAKES WITHIN ONE OF YOUR XML RESOURCE FILES WHICH CAUSES R TO NOT BUILD PROPERLY. THANKS FOR THE LINK.
The R file is a generated file, so you need to build the program in order to get the references to it. Make sure you check this answer to see how to rebuild it :
Android studio is based on Intellij Idea. In Intellij Idea you have to do the following from the GUI menu.
Build -> Rebuild Project
This question already has answers here:
How to get pid of android application without using adb shell?
(2 answers)
Closed 6 years ago.
Is there a way within a java app that's running under Android to determine that app's process ID ("PID")?
The reason I want this is that I am writing an app which reads and processes lines from logcat, and I want to be able to ignore all logcat lines that have been written by this app, itself.
I know I can do this by using a unique tag for my app in all the Log.*() calls and then ignoring logcat lines with this tag, but it seems to me that it would be cleaner if I could simply ignore all logcat lines which have been written by my own app's PID.
I've searched, but I couldn't find anything which explains how to determine the PID of a running Android app, from within that app, itself.
Thanks in advance for any suggestions or pointers to docs.
You're looking for this, I think:
int id = android.os.Process.myPid();
This question already has answers here:
Writing Eclipse plugin to modify Editor Preferences
(3 answers)
Closed 8 years ago.
I am working on a Eclipse plugin and I want to change some settings for the user in able to be able to use the plugin correctly
I need to make some changes in the settings of Eclipse using the code instead
For example:
If I want to access Window-Open perspective-Debug
Instead of telling the user these steps, I want to make it in the code
Any help ?
You have to be more specific, otherwise you're only going to end up at http://www.eclipse.org/eclipse/platform-core/documents/user_settings/faq.html . Your example is a bad one since you shouldn't be changing the perspective without the user's consent. Even then, that's not a Preference, that's an API call: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IWorkbenchWindow.html#openPage(java.lang.String, org.eclipse.core.runtime.IAdaptable) .
Your plug-in should not require the user to be in any specific perspective. They should be free to arrange the editor and views any way they like.