I have 4 layouts(views) and I wanna get their shortcuts.
I use "getDrawingCache()",yeah,I get the pictures,but I found if I wanna get the pictures,I had to make them shown.(I mean they have to be displayed to the user).
So Is there any way to get their pictures without displaying them??
Thanks in advance!
This might work
Window window = getLocalActivityManager().startActivity(Id,intent.addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP));
window.getDecorView().buildDrawingCache();
window.getDecorView().getDrawingCache();
This is what is done to update activities in tab activity. Im not sure but its worth a try.
Related
I'm designing a spaceship game in App Inventor. I have a label (lblScore) update when the ship is hit each time. When the ship is hit 3 times, I want the code inside that to execute yet it doesn't work. I've tried multiple variations of this, such as setting it to lblScore.Text instead. Any idea's on how I can address the issue?
Is the lblscore a label?
If it is all you need to do is have a collision block saying whenever the spaceship gets hit, set lblscore = lblscore + 1
This should fix your issue but I would like to see all of your blocks
Do you increment your lblScore in the Ship.CollidedWith event?
If yes, you should move your if statement there, but instead of using the lblScore component as currently, you should better use the lblScore.Text property instead.
Probably it would help us to help you, if you provide a screenshot of your Ship.CollidedWith event...
I am working a project. I have lots of word text data and don't want to add layout and class for each one. I want to use sqlite, but don't know how. For example, there is a button, id is cat.
When clicking the cat button, a new screen opens and shows information of cat. One layout, one class, but lots of screens. The data must come from sql because there are too many animals.
Thanks in advance.
You have given the answer already yourself: SQL database may be your friend. Work yourself through this tutorial and see how far that brings you. You'll have to manipulate the UI from code, that is doable as well.
Another approach you might want to consider is putting everything in XML into strings.xml file(s). This depends a bit on the size and structure of your data. From code you can reach this using getString( R.id.blah ).
Call other screen passing values.
In the button click do:
startActivity(new Intent(this, SecondScreen.class).putExtra('Identify', 'Value'));
In the Second Screen do:
String value = getIntent().getStringExtra('Identify');
Now, take that value and make the query in SqLite and display the result.
I want to load an asset and the only way I can see to do that is with
Context.Assets.Open();
I don't see a way to get access to Context without passing it around. I really don't want to pass it around
To answer my own question:
Application.Context.Assests.Open()
is what I was looking for. For some reason I just couldn't see it.
Hi I need a little help with an issue that I have.
I had to build an application which needs to show only a text information and pictures.The content was a lot, that's why instead of creating 200 single activities for very page I create one base activity which content I'm changing everytime depends on which listview item is clicked using putExtra(); and getExtra();. So the problem now is that they want me to create Favourites page, where the users can save some of the information and access them on a single activity.Actually it's really easy to do this using sqlite,but they want from me to finish the application today, within a few hours.My problem is that If i start coding it again and insert all that information in database it will take much more time for me.
So here is a little more explanation :
1.I have base activity with a listview.
2.When user click on listview item I send the content using putExtra in base activity.
So I need to learn how to save the id of listview item or something else and show that content in new Activity. I was thinking of using SharedPreferences but not really sure how to deal with that.
Any suggestions how I can do that...for a few hours.
Thanks in advance!
What kind of content is it? Is it over 200 entries and you don't save them locally?
Just knowing if it's a favorite or not can not be more than one hour job using sqlite. Just keep the id of the content and then a value to see if it's a favorite or not.
Noone will really do that for you since it's obviously your (paid?) job. The fact that you can't do it in time is really not a reason to skip the best option to use.
I would say don't be that optimistic about what you can achieve in which time. Manage your resources better and you will not have that problem.
You can achieve this with sharedpreferences too,but it's not a good idea.
The best way is to do it with database,but it's up to you.
So, what I'm actually looking for is this solution: Get/pick an image from Android's built-in Gallery app programmatically but working in a preference and not in an activity.
I created a class that I put in my setting and I want to use that class to be able to find the URI of an image selected by the user on its phone. I couldn't use the code in that link because of "startActivityForResult". Which is not available in a preference.
Any idea how to bypass this ?
PROGRESS REPORT:
So, I tried some stuff in the mean time. Instead, in my settings, I added the following:
<Preference
android:key="test"
android:title="open image"
android:persistent="true">
<intent android:action="android.intent.action.GET_CONTENT"
android:value="image/*"/>
</Preference>
First, instead of "GET_CONTENT", it was "PICK", but with it, I can only go with Google Docs and the Sim Card Tool Kit, which is far from the gallery or any thing to browse the file system.
With "GET_CONTENT", it crashes.
I also added the "android.permission.WRITE_EXTERNAL_STORAGE" premission, even if I just want to read. But I didn't found any (let put this as a sub question, if there's a way to just ask to read and not write).
PROGRESS REPORT #2
I replaced android:value by android:mimeType and I goes directly to the gallery. Now, just need to know if I really got the URI and it's solved.
PROGRESS REPORT #3
At this point, here's the real problem. When I go through my SharedPreferences, the value stays empty, even after selecting an images. So, I guess there a little hack to do. So now, that's the question. Based on the example of my preference screen above, how can I retrieve the value of "test", assuming that when the intent is called, it put it somewhere ?
I finally found a solution... it's not as feng shui as I would like, but it works.
I simply code the preference screen by hand and then I was able to access the "startActivityForResult" function.
From this point, it took 3 to 5 minutes to solve it and finalize all the details.
Hope it helps some people.
You have an example there: http://www.anddev.org/code-snippets-for-android-f33/preference-screen-with-custom-views-t8472.html
But the one I used was on google, but I couldn't find the link.