Update UI in window service. - Java for Android App Development

Hi XDA-Developers!
I need your help with this little problem, I hope that anybody could help me
I have an Activity with this:
Code:
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mLinearLayout = (RelativeLayout)inflater.inflate(R.layout.systemoverlayout, null);
wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
int height = displaymetrics.heightPixels;
int PhoneHeight = height;
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
PhoneHeight,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.CLIP_HORIZONTAL | Gravity.TOP;
wm.addView(mLinearLayout, params);
That displays a layout as a Window.
My problem is easy, How can I update the UI (change text of a TextView) when this window is showing?
When I try it with "***.setText("****");" I get Foce close.
Any Help?
Thank's and happy christmas!!
Enviado desde mi GT-S5570I usando Tapatalk 2

Any Help? Pleasee
Enviado desde mi GT-S5570I usando Tapatalk 2

Please post your LogCat!

If it's a view, you won't need to refresh anything, it's done automatically for you .
You normally don't get a FC on calling setText, make sure you have the correct view! So you'd call:
Code:
TextView tv = (TextView) findViewById(R.id.yourTextViewId);
tv.setText(R.string.yourText);
And for your errors make sure to read nikwen's awesome guide on debugging here.

EmptinessFiller said:
Please post your LogCat!
Click to expand...
Click to collapse
Sorry, I'm in mobile phone.
Enviado desde mi GT-S5570I usando Tapatalk 2

SimplicityApks said:
If it's a view, you won't need to refresh anything, it's done automatically for you .
You normally don't get a FC on calling setText, make sure you have the correct view! So you'd call:
Code:
TextView tv = (TextView) findViewById(R.id.yourTextViewId);
tv.setText(R.string.yourText);
And for your errors make sure to read nikwen's awesome guide on debugging here.
Click to expand...
Click to collapse
The error gives FC in the line that setText in the TextView.
tv.setText("Error"); //Here!!
Why? Any help?
Thank's!
Enviado desde mi GT-S5570I usando Tapatalk 2

DannyGM16 said:
The error gives FC in the line that setText in the TextView.
tv.setText("Error"); //Here!!
Why? Any help?
Thank's!
Click to expand...
Click to collapse
Well I'd guess it is a NullpointerException but without Logs it's not clear. How did you initialise the tv? If done right with findViewById, it should not be null. Please post some more code and read the debugging guide again!
Edit: You may need to call mLinearLayout.findViewById(...) instead of this.findViewById() if you still have that LinearLayout!

SimplicityApks said:
Well I'd guess it is a NullpointerException but without Logs it's not clear. How did you initialise the tv? If done right with findViewById, it should not be null. Please post some more code and read the debugging guide again!
Edit: You may need to call mLinearLayout.findViewById(...) instead of this.findViewById() if you still have that LinearLayout!
Click to expand...
Click to collapse
I SOLVED IT WITH FOR HELP!! Lot's of thanks friend!

DannyGM16 said:
I SOLVED IT WITH FOR HELP!! Lot's of thanks friend!
Click to expand...
Click to collapse
Great!
(and that is my 200th post )

SimplicityApks said:
Great!
(and that is my 200th post )
Click to expand...
Click to collapse
CONGRATULATIONS!!
Enviado desde mi GT-S5570I usando Tapatalk 2

Related

Can I put comments on an update.zip file?

I want to create an update.zip file for a certain purpose and since it's quite a big thing, it'd be nice if I could comment on each step so that I don't get lost. Is it possible to add comments to an update.zip?
Yes it is.
Add such a line for every comment to your updater-script:
ui_print("Hello World!");
Regards
Mmm, I meant comments as text that I want to appear in the script, but I don't want to be ran or displayed.
For example:
Code:
ui_print("Hello World!");
[B]# this command shows the words "Hello World!" in the screen[/B]
Logseman said:
Mmm, I meant comments as text that I want to appear in the script, but I don't want to be ran or displayed.
For example:
Code:
ui_print("Hello World!");
[B]# this command shows the words "Hello World!" in the screen[/B]
Click to expand...
Click to collapse
yes should work
make sure u save the file in UNIX format
BTW why u posting this in Dev section? isnt this more suitable in General section?
Now that you mention it... I'll report it.
What do you mean, saving it in UNIX format?
Enviado desde mi R800i usando Tapatalk
Logseman said:
Now that you mention it... I'll report it.
What do you mean, saving it in UNIX format?
Enviado desde mi R800i usando Tapatalk
Click to expand...
Click to collapse
Make sure your using an edify script too. CWM no longer supporty ammend scripts.
Sent from my R800i using Tapatalk

Execute commands in AsyncTask

Hi everybody! I'm developing a Root app and I want to add an AsyncTask that runs a Root command in background, and, onPreExecute and onPostExecute runs a processdialog. Can anybody teach me how to do it?
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
DannyGM16 said:
Hi everybody! I'm developing a Root app and I want to add an AsyncTask that runs a Root command in background, and, onPreExecute and onPostExecute runs a processdialog. Can anybody teach me how to do it?
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Click to expand...
Click to collapse
I have seen another similar post of yours.
Here is a relatively simple way of showing and hiding a progress. There are a number of ways of doing this as you have probably already seen, this is just another way. Your ProgressBar (xml) needs to exist in your layout.
Code:
new AsyncTask<Void, Void, Void>() {
[user=439709]@override[/user]
protected void onPreExecute() {
((View) view.findViewById(R.id.your_progressbar_in_layout)).setVisibility(View.VISIBLE);
}
[user=439709]@override[/user]
protected Void doInBackground(Void... params) {
// Whatever you are executing off the UI thread
return null;
}
[user=439709]@override[/user]
protected void onPostExecute(Void result) {
((View) view.findViewById(R.id.your_progressbar_in_layout)).setVisibility(View.GONE);
}
}.execute();

[Must See Guide] Make your app transparent as u like

THIS IS GUIDE TO ADD DIFFERENT TRANSPARENCY LAVELS TO YOUR ANDROID APP...
JUST ADD THE FOLLOWING CODES TO YOUR APP AND U R DONE
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams params = this.getWindow().getAttributes();
/**
* 0.8f sets the activity to 80% opaque;
* similarly if u decrease the float value then it will increase your transparency
*/
params.alpha = 0.8f;
}
AND IN YOUR MANIFEST FILE REPLACE "ANDROID THEME" WITH THESE LINES
android:theme="@android:style/Theme.Translucent.NoTitleBar"
OR SIMPLE CHOOSE TRANSLUCENT THEME FOR YOUR APP
I HAVE ATTACHED A " SAMPLE TRANSPARENCY " PROJECT ALONG WITH A SIMPLE COMPILED APK
Please add [GUIDE] to the title of the thread. I thought it was a question.
Please make it as a downloadable txt file...
Sent from my Xperia U using xda app-developers app
Now see the attachements for better understanding
Now i have attached a sample transparency project and a sample apk...
anurag.dev1512 said:
THIS IS GUIDE TO ADD DIFFERENT TRANSPARENCY LAVELS TO YOUR ANDROID APP...
JUST ADD THE FOLLOWING CODES TO YOUR APP AND U R DONE
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams params = this.getWindow().getAttributes();
w.getDefaultDisplay().getSize(size);
/**
* 0.8f sets the activity to 80% opaque;
* similarly if u decrease the float value then it will increase your transparency
*/
params.alpha = 0.8f;
}
AND IN YOUR MANIFEST FILE REPLACE "ANDROID THEME" WITH THESE LINES
android:theme="@android:style/Theme.Translucent.NoTitleBar"
OR SIMPLE CHOOSE TRANSLUCENT THEME FOR YOUR APP
I HAVE ATTACHED A " SAMPLE TRANSPARENCY " PROJECT ALONG WITH A SIMPLE COMPILED APK
Click to expand...
Click to collapse
Tnx for the code. :good:
thanks for complement
a-ssassi-n said:
Tnx for the code. :good:
Click to expand...
Click to collapse
if u really liked my code then u will obviously like me transparent themed app...
https://play.google.com/store/apps/details?id=org.ultimate.tasker
anurag.dev1512 said:
if u really liked my code then u will obviously like me transparent themed app...
https://play.google.com/store/apps/details?id=org.ultimate.tasker
Click to expand...
Click to collapse
Already downloaded and used.
nice work.
anurag.dev1512 said:
if u really liked my code then u will obviously like me transparent themed app...
https://play.google.com/store/apps/details?id=org.ultimate.tasker
Click to expand...
Click to collapse
IDE says unknown variable w and size
Sent from my GT-S5570 using XDA Premium 4 mobile app
anurag.dev1512 said:
THIS IS GUIDE TO ADD DIFFERENT TRANSPARENCY LAVELS TO YOUR ANDROID APP...
JUST ADD THE FOLLOWING CODES TO YOUR APP AND U R DONE
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams params = this.getWindow().getAttributes();
w.getDefaultDisplay().getSize(size);
/**
* 0.8f sets the activity to 80% opaque;
* similarly if u decrease the float value then it will increase your transparency
*/
params.alpha = 0.8f;
}
AND IN YOUR MANIFEST FILE REPLACE "ANDROID THEME" WITH THESE LINES
android:theme="@android:style/Theme.Translucent.NoTitleBar"
OR SIMPLE CHOOSE TRANSLUCENT THEME FOR YOUR APP
I HAVE ATTACHED A " SAMPLE TRANSPARENCY " PROJECT ALONG WITH A SIMPLE COMPILED APK
Click to expand...
Click to collapse
Hi Bro Can you please elaborate more on how to add these codes as I am not aware of this so can u please guide properly with steps to do.
Do i need any application on my laptop or mobile
pls reply
Thanks
That's for your own app only. So you don't need anything expect the normal developer stuff (eclipse or androidstudio). Then just add above to your Activity and below to your manifest.
arpitkh96 said:
IDE says unknown variable w and size
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
hi bro... just see the attachments that i have attached along with with sample apk...
and line plzz make w.getDefaultDisplay().getSize(size); as a comment and u r done.....
EmptinessFiller said:
That's for your own app only. So you don't need anything expect the normal developer stuff (eclipse or androidstudio). Then just add above to your Activity and below to your manifest.
Click to expand...
Click to collapse
yeah bro theaming and modding of the app is done by the developer side and adjusting the transpareny of the app is one of the theming of your app and adds beauty..to your app..........
i am not able to get your question properly ...
you mean what kind of software u need to develop apps for android or what...
plzzz ask...

[TUTORIAL] Translate a ROM using Github

Hi guys this is my first tutorial here!
I'm not a developer but i want to contribute for the community, so some time ago i started translation of my favourite rom, the Mahdi ROM. That was about March 2014. As of now I've started a new project: translations for Chroma ROM (June 2015)
You need only one thing: the rom has to be open source on github.
So, let's start.
First, go to the rom sources on github and open the apk you want to translate. The most important directories are three:
Settings in /android_packages_apps_Settings
SystemUI in /android_frameworks_base/packages/systemUI
Core in /android_frameworks_base/core
1) to find file(s) to translate you have to go in the directory and then in the folder res.
2) now, it's full of folders but you only need two of them. open in two tabs of your browser values and values-xx (xx are two letters that determinate your language, e.g. "it" for italian and "fr" for french).
3) in values you have to find the file "name-of-the-rom-strings.xml". this is the file you'll translate. now in values-xx, open the file "name-of-the-rom-strings.xml" and click on edit. probably in values-xx folder you won't find the file "name-of-the-rom-strings.xml", if so, click on the "+" near to the name of the directory and create a new file called like the previous one. remember the extension (.xml)
4) now, copy all strings from "name-of-the-rom-strings.xml" in values and paste in the file you were editing in values-xx. now you are ready to translate the rom, read tips down here.
Click to expand...
Click to collapse
What if the folder values-xx doesn't exist?
No problem. Click on the "+" icon to create a file, and write values-xx/***. The slash create a new folder. Et voilà!
Click to expand...
Click to collapse
READ:
1) you only have to translate what's between ><
2) before every ' , add a slash like this \, so if you want to write don't, write don\'t
3) DO NOT translate strings which say translatable=false, delete those strings
4) do not add >< or "" or "string". just change what's between ><. Good luck!
Click to expand...
Click to collapse
Great guide ?
N⁴
Oooops i forgot to say how to create a pull request and some other stuff, working on it now
Inviato dal mio Nexus 4 usando XDA App
Thanks for this tutorial!
I do have a question.
I'm tring to translate every single English word to my language (Dutch)
But where do I find the words that are still in English?
In the picture I uploaded are 2 examples.
You see 'UI Settings' and 'Performance' still in English.
Can you help me?
Tommebaas said:
Thanks for this tutorial!
I do have a question.
I'm tring to translate every single English word to my language (Dutch)
But where do I find the words that are still in English?
In the picture I uploaded are 2 examples.
You see 'UI Settings' and 'Performance' still in English.
Can you help me?
Click to expand...
Click to collapse
Mmh, this is all something you should find in settings files. Try to use ctrl+f in the file and write what you're looking for . Btw what rom is that?
Inviato dal mio Nexus 4 utilizzando Tapatalk
toyr99 said:
Mmh, this is all something you should find in settings files. Try to use ctrl+f in the file and write what you're looking for . Btw what rom is that?
Inviato dal mio Nexus 4 utilizzando Tapatalk
Click to expand...
Click to collapse
Thanks
Mahdi of course!
Tommebaas said:
Thanks
Mahdi of course!
Click to expand...
Click to collapse
Found it?
Inviato dal mio Nexus 4 utilizzando Tapatalk
toyr99 said:
Found it?
Inviato dal mio Nexus 4 utilizzando Tapatalk
Click to expand...
Click to collapse
I've been really busy lately and haven't had much time. I will report to you asap
Sent from my Nexus 4
I've just pushed my first translations on Github. Thanks for this useful guide :good:
Primokorn said:
I've just pushed my first translations on Github. Thanks for this useful guide :good:
Click to expand...
Click to collapse
toyr99 said:
Click to expand...
Click to collapse
How do u check if some translations have already been pushed without being validated?
A guy just told me that he already sent a request for a part of my translations but I didn't see them before starting to translate. Everything was in English on the "rom_strings.xml" file into values-fr folder.
actually, i don't know :c
toyr99 said:
actually, i don't know :c
Click to expand...
Click to collapse
Here is the answer:
1. From the main page of a package eg "Mahdi-Rom/android_packages_apps_Settings" click on "Pull requests" on the right (if any)
2. Select a commit
3. Select "Files changed" tab
4. We can see the original lines in red and the modifications in green
Op updated for when there isn't values-xx folder in the package ?
Inviato dal mio Nexus 4 utilizzando Tapatalk
Hi,
I want to start translating the English stuff to Dutch.
And I noticed there is not a mahdi_strings.xml in Dutch yet.
So I have to add that right?
But there is so much to translate from mahdi_strings.xml.
A lot of English words are probably already translated.
How do I figure that out?
Tommebaas said:
Hi,
I want to start translating the English stuff to Dutch.
And I noticed there is not a mahdi_strings.xml in Dutch yet.
So I have to add that right?
But there is so much to translate from mahdi_strings.xml.
A lot of English words are probably already translated.
How do I figure that out?
Click to expand...
Click to collapse
Which package do u want to translate? Coz dutch translations already exist like the FW.
Primokorn said:
Which package do u want to translate? Coz dutch translations already exist like the FW.
Click to expand...
Click to collapse
That's German
Just all the English words that still exists.
Tommebaas said:
That's German
Just all the English words that still exists.
Click to expand...
Click to collapse
Oups ^^
About android_frameworks_base there's only one request for the moment so you can translate the GERMAN part. Edit the file then enter your modifications and send your request.
Primokorn said:
Oups ^^
About android_frameworks_base there's only one request for the moment so you can translate the GERMAN part. Edit the file then enter your modifications and send your request.
Click to expand...
Click to collapse
So I just make a new line under the last translatings and send the request?
Tommebaas said:
So I just make a new line under the last translatings and send the request?
Click to expand...
Click to collapse
Yep

How to edit learned words

Hello, I would like to know how to view and edit the list of learned words from the Samsung keyboard on Nougat , because I do not find where, any know? Thank you
Enviado desde mi SM-G935F mediante Tapatalk
nestori said:
Hello, I would like to know how to view and edit the list of learned words from the Samsung keyboard on Nougat , because I do not find where, any know? Thank you
Enviado desde mi SM-G935F mediante Tapatalk
Click to expand...
Click to collapse
I don't think you can "edit" them.
You can delete them by just typing the word you want and then pressing the > arrow next to the suggestions that pop up then holding the word down and press remove.
To delete all and start fresh you can go;
Settings > General Management > Language And Input > On-Screen Keyboard > Samsung Keyboard > Reset To Default Settings > Clear Personalized Data

Categories

Resources