[LIBRARY][GUIDE] DynamicShareActionProvider
Some time ago I had a conversation with @SimplicityApks about Google's ShareActionProvider. We found out that it's not flexible enough as it doesn't allow dynamic generation of the data which should be shared.
So here I release my open-source DynamicShareActionProvider library. Its code can be found on Github.
The differences:
Sharing is done dynamically now!
This means that your app specifies the type of the shared data first and generates the data when an app is chosen for sharing. No more need to define what to share when the Activity is created. The content can now be set dynamically.
There are two types of listeners so that you can also generate the data in an AsyncTask.
There is no app icon of the most often used app appearing next to the share icon.
Other icons often do not match the app theme.
The shown app list is not limited to three apps and a "See all" entry first.
Why should the user not see all apps for that action?
You can adjust/must set the icon manually.
Don't worry.
Screenshots:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
(The second screenshot is from the app FunctionCapture by @SimplicityApks)
Big thanks to:
@SimplicityApks for some ideas
This was featured on the XDA portal on December 20, 2013.
[GUIDE] Adding this to your app
As indicated in the first post, the implementation is a little bit different than with Google's ShareActionProvider.
I assume that you are using Google's ActionBarCompat library.
Add the ActionBarCompat and the DynamicShareActionProvider library to your project first.
Afterwards, there are two ways of sharing your data using the DynamicShareActionProvider:
You can pass the data to the library when an app is selected and it will do the sharing part.
Or the library gives you an Intent which you just need to add the data to. This allows using an AsyncTask for data generation.
Adding the provider to the menu file
The first steps are the same for both ways. Add this to your menu resource file:
Code:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:library="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_item_share"
library:showAsAction="always"
android:title="Share"
android:icon="@drawable/abc_ic_menu_share_holo_dark"
library:actionProviderClass="de.nikwen.dynamicshareactionprovider.library.DynamicShareActionProvider" />
<!-- Your other entries here -->
</menu>
I saved the menu file as "res/menu/main.xml".
What's different from Google's Provider here, is that you need to set the icon for the menu entry. That shouldn't be a problem though because we can use the one from the ActionBarCompat library.
Then inflate the menu resource in the onCreateOptionsMenu() method of your Activity and get the provider from the menu:
Code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
DynamicShareActionProvider provider = (DynamicShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_item_share));
return true;
}
Set the data type
To be able to filter your installed apps for those that can handle the data which should be shared, the provider needs to know which type of data you want to share. Set it like this:
Code:
provider.setShareDataType("text/plain");
(Add this to your onCreateOptionsMenu() method.)
Two different types of listeners
Now you need to choose the way you want to do the sharing:
If the generation of the data which should be shared takes much time so that you want to use an AsyncTask or a Service for that, use the DynamicShareActionProvider.OnShareLaterListener.
Otherwise use the DynamicShareActionProvider.OnShareIntentUpdateListener.
Click to expand...
Click to collapse
Using the OnShareIntentUpdateListener - Let the library do the sharing for you
Set the listener using the setOnShareIntentUpdateListener() method:
Code:
provider.setOnShareIntentUpdateListener(new DynamicShareActionProvider.OnShareIntentUpdateListener() {
@Override
public Bundle onShareIntentExtrasUpdate() {
Bundle extras = new Bundle();
//Generate your data here and add it to the Bundle
return extras;
}
});
(Add this to your onCreateOptionsMenu() method as well.)
We override the onShareIntentExtrasUpdate() method here and pass a Bundle as the return value. The data you add to the bundle should have the same format that you would use, if you added it to the Intent directly using the Intent#putExtras(Bundle extras) method (that's what is used internally).
This is an example for passing the data from an EditText:
Code:
@Override
public Bundle onShareIntentExtrasUpdate() {
Bundle extras = new Bundle();
EditText shareEdit = (EditText) findViewById(R.id.share_edit);
extras.putString(android.content.Intent.EXTRA_TEXT, shareEdit.getText().toString());
return extras;
}
You're done.
Using the OnShareLaterListener - Do the sharing yourself
This time we override the onShareClick() method of the OnShareLaterListener:
Code:
provider.setOnShareLaterListener(new DynamicShareActionProvider.OnShareLaterListener() {
@Override
public void onShareClick(Intent shareIntent) {
MyShareAsyncTask task = new MyShareAsyncTask();
task.execute(shareIntent);
}
});
We get the share Intent as an argument and don't have to pass a return value. Instead, we have to do the sharing part manually.
The example code uses an AsyncTask for that:
Code:
private class MyShareAsyncTask extends AsyncTask<Intent, Void, Intent> {
@Override
protected void onPreExecute() {
Toast.makeText(MainActivity.this, R.string.asynctask, Toast.LENGTH_LONG).show();
}
@Override
protected Intent doInBackground(Intent... intents) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
EditText shareEdit = (EditText) findViewById(R.id.share_edit);
intents[0].putExtra(android.content.Intent.EXTRA_TEXT, "Shared from an AsyncTask: " + shareEdit.getText().toString());
return intents[0];
}
@Override
protected void onPostExecute(Intent intent) {
startActivity(intent);
}
}
However, you're free to do it the way you like.
You're done.
Get the sample code
It's on Github: Link to the sample code
Other stuff
See (and maybe share) my Google Plus post on the library.
Let me know if you add this to your app. I will really appreciate it.
Well, it's time to say thank you again^^, without your lib sharing in my app wouldn't be nearly as useful... Thanks soo much! :good:
SimplicityApks said:
Well, it's time to say thank you again^^, without your lib sharing in my app wouldn't be nearly as useful... Thanks soo much! :good:
Click to expand...
Click to collapse
Thank you very much for the compliments.
And welcome.
It's among the top trending Java repos on Github today. Currently, it's at position #14.
Screenshot:
(I know that the screenshot still shows #16. Old one. )
EDIT: The best I saw was position #11.
Hey congrats for the portal post about ur lib
:good:
---------------------------------
Phone : Samsung Galaxy Mini S5570
OS:
•AOSP ICS Touchwiz V5 by A_U
•Android 4.0.4
•Baseband XWKS2
•Kernel: 2.6.37.6 Badass v1.9 by alin.p
•Recovery CWM v4.0.0.5
Mods:
PureAudio, Mounts2SD, ODEX through Universal ODEX script, AdBlock by AdAway
---------------------------------
Gesendet von Tapatalk
Very nice for us devs! Thanks, I will look where to implement this
Masrepus said:
Hey congrats for the portal post about ur lib
:good:
---------------------------------
Phone : Samsung Galaxy Mini S5570
OS:
•AOSP ICS Touchwiz V5 by A_U
•Android 4.0.4
•Baseband XWKS2
•Kernel: 2.6.37.6 Badass v1.9 by alin.p
•Recovery CWM v4.0.0.5
Mods:
PureAudio, Mounts2SD, ODEX through Universal ODEX script, AdBlock by AdAway
---------------------------------
Gesendet von Tapatalk
Click to expand...
Click to collapse
lesiki said:
Very nice for us devs! Thanks, I will look where to implement this
Click to expand...
Click to collapse
Big thanks to both of you.
Just pushed an update to the library which adds support for ActionBarSherlock and the native ActionBar. I haven't changed the readme-file yet as I'm currently looking for someone to test those versions in his app. Would be great if someone (maybe you?) did it.
If you're interested in the update, have a look at the issue on Github: Issue #2
@nikwen
Great work there !
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
@nikwen
Great work there !
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Thanks.
How can i prevent default action?
i want to override action for facebook.
Related
myStore FIRST OpenSource custom Store for all Sense base ROMs
OPEN SOURCE Grab it on GitHub
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Now all Devs can use this app to create their own "Store" to provide for users banch of features from reading news to downloading apk files, zip files, ota updates and anything that dev willing to provide to YOU, user.
myStore works only on Sense Base ROMs and Support all Screen resolutions.
Android Versions as well From 4.0.3 up to 4.2.2
myStore as itself downloaded from here does not provide anything to user who install it. You need to wait when your ROM developer willing to use it and implement into the ROM.
I will not assist any USER who install it and complain that app doesnt work for you.
These are some rules and regulations on how you allowed to use it
These terms are for the myStore.apk itself
You are to send me PM to ask permission to use this application with Link to ROM Thread or post request here
You are to give credits to the creator, do not clame it as your work (See example in Elegancia thread)
You NEVER change my name in the Application or replace it with yours
You NEVER change Jonny's name in the Application or replace it
You NEVER change package name of the Application (now it is org.mikrosmile.my.store)
If following conditions are not met, it will be reported to the Moderator
This what you can do with the application
You can change app name as you wish
You can change app icon as you wish
You can change banner image in the application as you wish
You can change Tab names or icons as you wish
You can change any images in the app
Features:
Read latest News from your ROM Developer
Download Skins
Download Special System Mods in zip format
Download Kernels
Downalod any other desire files from your ROM developer
Install apk files within the app
HTC Sense Skin support
Requests:
You can ask me to add more Tabs in the application
You cannot ask me to add some features from DarkSense Store
Any other requests are welcome
Extra - will be new options for new myHUB
Official extended myStore holders
V6-Maniac
How to create news, Skins List, Mods List or any other
Application uses xml file format to read from your server.
There are news.xml , skins.xml , mods.xml , kernels.xml files
Each of them have their own layout and data.
news.xml
You can download example, or create yours
Code:
<?xml version="1.0" encoding="UTF-8"?>
<news>
<newsitem headline="This is your headlin. Dont make it long">
<text>This is your text for your news</text>
<date>10.04.2013</date>
<description></description>
<technical-details></technical-details>
<image-url></image-url>
</newsitem>
</news>
For you to make new field just copy everything inside <newsitem ></newsitem> tags for example
Code:
<?xml version="1.0" encoding="UTF-8"?>
<news>
[COLOR="Red"]<newsitem headline="This is new item">
<text>This is your text for your news</text>
<date>11.04.2013</date>
<description></description>
<technical-details></technical-details>
<image-url></image-url>
</newsitem>[/COLOR]
<newsitem headline="This is old news">
<text>This is your text for your news</text>
<date>10.04.2013</date>
<description></description>
<technical-details></technical-details>
<image-url></image-url>
</newsitem>
</news>
<image_url></image_url> is the small image to show that it is a new item.. for example
<image_url>http://yourserver.com/new_image.png</image_url>
If you dont need the image just remove link. DO NOT REMOVE TAGS
For all items do not make new lines inside xml. Otherwise the application will crash all the time. If your news is long, just type on the same line.
skins.xml + mods.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<news>
<newsitem headline = "Name of the Skin">
<text>Any text. I put Author name of the skin</text>
<description>http://yoursite.com/skin_name.zip</description>
<date></date>
<technical-details></technical-details>
<image-url>http://yoursite.com/skin_image.png</image-url>
</newsitem>
</news>
As you can see the entire xml is the same but uses different tags.
headline - now it is a name of the Skin
text - is any text you wish to put. I use it as Author name
description - is the link to the apk in your server. ALL FILES SHOULD BE PACKED IN ZIP. EVEN ZIP FILE PUT IT IN ANOTHER ZIP
image-url - link to the preview image of the skin.
You can use skins.xml example for MODs. It uses the same layout and the same info. But make sure you use different xml names
kernels.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<news>
<newsitem headline = "Kernel name">
<text>Kernel author name</text>
<description>http://yoursite.com/kernel_name.zip</description>
<date></date>
<technical-details></technical-details>
<image-url>http://yoursite.com/kernel.png</image-url>
<rom_desc></rom_desc>
</newsitem>
</news>
headline - Name of the Kernel
text - Kernel author
description - Link to the kernel on your server. Make sure you place kernel.zip into new zip
image-url - any image that you like to identify as it is a kernel, new item or anything
myStore configuration for Developers
Links to Server
Now myStore will get all information and links to your server from one single file myStore.txt in system folder.
myStore.txt -
HTML:
ro.news=http://yoursite.com/news/news.xml
ro.skins=http://yoursite.com/skins/skins.xml
ro.battery=http://yoursite.com/battery/battery.xml
ro.kb=http://yoursite.com/keyboard/keyboard.xml
ro.mods=http://yoursite.com/skins/skins.xml
ro.kernels=http://yoursite.com/kernels/kernels.xml
ro.name=Your name
ro.rom=Your ROM
ro.profile=http://
ro.thread=http://
ro.donate=http://
ro.twitter=http://twitter.com
make simple txt file and paste this info and place myStore.txt (follow letters formar as it) in root directory of System folder (where you have Build.prop)
And run application. If there is not file myStore will not work you will get Error.
myStore application Changelog and Download Links
Changelog:
myStore V2.3
Added coded link (Now you can remove link from configuration file and it will use coded empty data)
Added ability to install zip or apk file from any download page (in all download pages except Kernels)
myStore V2.2
Replaced hardcored names and links for profile and thead (For ROM developers)
Added Edit tabs to menu (Credits to Jonny)
Removed avatar images from About tab (not necessary to have them)
myStore V2.1
Replaced hardcored links to get them from myStore.txt file from System
Added Checking of the File in system
Added Mount system permission
myStore V2.0
Converted from Activities to Fragments (Support Sense 5)
Added Cube animation
Updated all backgrounds
Added Extra line in Kernels tab in Pop up - Add text in your xml into<technical-details></technical-details> tag
myStore V1.4
Added App version to header. It refers from manifest
Added "Based on myStore" to Header
Added more links to my name (Don't change position of names)
Updated all ProgressDialogs (Now uses Htc style)
Added Autoflash of Kernels and other zip files
Now list of files appear after finish of downloading (zip files)
Now requires SuperUser
myStore V1.3
Updated all background for all tabs
Updated Refresh button
Added Vibration on items click
Added Jonny to About page (Also non removable name from App)
Added Settings page
Added Ability to disable auto loading of list on start application (All Tabs)
myStore V1.2
Added Battery Mods Section
Added Keyboard Mods Section
MyStore V1.1
Added Network connection checking
MyStore V1.0
Initial release
Download: - DO NOT MAKE ANY MIRRORS
Screenshots:
ROMs using MyStore
[ROM][SENSATION]ELEGANCIA™ Rom Series | Sense 4.1
[*][ROM][SENSATION] IronByte ROM |2.0.0|Sense 4.1|OTA|HUB|APM|EQS|
[ROM][DROID DNA]Hatka Supreme Sense 5.0
[ROM][DESIRE X]Sense.Revolution Sense 4.1
[ROM][DESIRE HD]SVHD [Android 4.0.4][Sense 4.1 Full]
[ROM][INCREDIBLE S]SVHD [Android 4.0.4][Sense 4.1 Full][OTA]
[*][ROM][DESIRE S]SVHD [Android 4.0.4][Sense 4.1 Full][OTA]
Compilation BUGS
If you have BrutForce error while decompiling the app, remove xxhdpi folder from project and compile again
If the application wont show after compilation try to insert back original meta-inf folder or make sure that in VTS in build properties you keep old signature
When downloading file if the progress bar is not moving, means your zip has UpperCase letters. Rename all zips to lowerCase. For example Blue_Glass.zip to blue_glass.zip
waiting for download link
Awesome.
Open source community...congrts...
Can you do for any aosp ROM too? Thanks
Enviado desde mi HTC Sensation usando Tapatalk 2
mondaza said:
Can you do for any aosp ROM too? Thanks
Enviado desde mi HTC Sensation usando Tapatalk 2
Click to expand...
Click to collapse
can
Good job!!
I like your attitude sharing knowledge and wisdom to the community!!
Keep up the good work :good:
Thread FINISH.. downalod link added.. Enjoy
Pls Devs DO follow my rules.. and users, rate thread if you like it
Great initiative mikro! Thank you for sharing your work!!
this is really great...
innovative and easy to use for any ROM modders
Nice job Mikro
Sent from my HTC Sensation Z710e using xda premium
Mikro,
Your my hero.
Thx
MyStore V1.1
Added Network connection checking
Forgot in first release
OP updated. Thanks to V6-Maniac. Also you need to change links in classes with XXXX$GetXMLTask at the end.
I didnt notice that smali is more different from java :silly:
This is what this forum need...
Keep up the awesome work.
Thanks Mikro
Sent from my HTC Sensation using DD premium APP.
Elegancia - Sense 4.1 has his first MyElegancia via OTA
Already said thx to Mikro via Talk but can't thank him enough...:good:
This is what i call share in a shareing forum
BanB said:
This is what i call share in a shareing forum
Click to expand...
Click to collapse
Exact
Отправлено с моего Sony Tablet S через Tapatalk
I update SDK to 22.0.1 and did related ADT updates. After updates my successfully running code has broken down with following error in finding xml resource-
unable to resolve static field 1108 (layout_name) in pkgname/R$layout
.
.
.
some error log....
.
.
.
java.lang.NoClassDefFoundError: pkgname.R$layout
Please tell me what can be the reason of this error and how can I resolve it?
Code:
class ProblemFixer extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
tryToFixTheProblem();
}
protected void tryToFixTheProblem()
{
try
{
cleanProject();
}
catch(FailedToFixProblemException e)
{
boolean isProblemFixed = new RestartExclipse().execute().getResponse();
if(isProblemFixed)
{
enjoy();
}
else
{
deleteAndReimportProject();
}
}
}
private void deleteAndReimportProject()
{
if(success)
{
enjoy();
}
else
{
finish();
//TODO: Open browser and search for solution;
}
}
}
Sent from my U8120 using Tapatalk 2
pedja1 said:
Code:
class ProblemFixer extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
tryToFixTheProblem();
}
protected void tryToFixTheProblem()
{
try
{
cleanProject();
}
catch(FailedToFixProblemException e)
{
boolean isProblemFixed = new RestartExclipse().execute().getResponse();
if(isProblemFixed)
{
enjoy();
}
else
{
deleteAndReimportProject();
}
}
}
private void deleteAndReimportProject()
{
if(success)
{
enjoy();
}
else
{
finish();
//TODO: Open browser and search for solution;
}
}
}
Sent from my U8120 using Tapatalk 2
Click to expand...
Click to collapse
Haha. :laugh:
Good job. :good:
That was funny lol.
So to recap, Clean your project and restart eclipse. If still doesn't work, delete your project and reimport it.
Cleaing project usualy fixes NoClassDefFound error, if it doest he can also try to restart eclipse and/or reimport project
Sent from my U8120 using Tapatalk 2
pedja1 said:
Code:
class ProblemFixer extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
tryToFixTheProblem();
}
protected void tryToFixTheProblem()
{
try
{
cleanProject();
}
catch(FailedToFixProblemException e)
{
boolean isProblemFixed = new RestartExclipse().execute().getResponse();
if(isProblemFixed)
{
enjoy();
}
else
{
deleteAndReimportProject();
}
}
}
private void deleteAndReimportProject()
{
if(success)
{
enjoy();
}
else
{
finish();
//TODO: Open browser and search for solution;
}
}
}
Sent from my U8120 using Tapatalk 2
Click to expand...
Click to collapse
Can I have the XML for this too?
:laugh:
Your project properties --> Build Path --> Order and Export --> check on Android Private Libraries
Hi XDA-Developers users!
I'ts easy, how can I make this processdialog visible?
Code:
public void onClick(DialogInterface dialog, int id) {
// metodo que se debe implementar
dialog.cancel();
pd = ProgressDialog.show(FixWifiActivity.this, "dialog title", "dialog message", true);
try {
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
} catch (IOException e) {
}
// TODO Auto-generated method stub
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} });
AlertDialog alert = builder.create();
alert.show();
}
}
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Please...
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Come on... It's easy...
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Do it like this:
Code:
ProgressDialog pd = new ProgressDialog(context);
pd.setTitle("My title");
pd.setMessage("Operation...");
pd.show();
nikwen said:
Do it like this:
Code:
ProgressDialog pd = new ProgressDialog(context);
pd.setTitle("My title");
pd.setMessage("Operation...");
pd.show();
Click to expand...
Click to collapse
Ok, I'm going to try it
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
nikwen said:
Do it like this:
Code:
ProgressDialog pd = new ProgressDialog(context);
pd.setTitle("My title");
pd.setMessage("Operation...");
pd.show();
Click to expand...
Click to collapse
No no no, you don't understand me What I mean is that I want to make the ProgressDialog visible becouse the reboot process block it.
Try to make a code that shows the ProcessDialog and then give it to me. Please...
EDIT:
What I want is show a progress dialog while a process is running, I think I need something like asynktask.
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
alert.show(); does not work?
alert.show(); does not work?
DannyGM16 said:
Hi XDA-Developers users!
I'ts easy, how can I make this processdialog visible?
Code:
public void onClick(DialogInterface dialog, int id) {
// metodo que se debe implementar
dialog.cancel();
pd = ProgressDialog.show(FixWifiActivity.this, "dialog title", "dialog message", true);
try {
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
} catch (IOException e) {
}
// TODO Auto-generated method stub
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} });
AlertDialog alert = builder.create();
alert.show();
}
}
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Click to expand...
Click to collapse
DannyGM16 said:
No no no, you don't understand me What I mean is that I want to make the ProgressDialog visible becouse the reboot process block it.
Try to make a code that shows the ProcessDialog and then give it to me. Please...
EDIT:
What I want is show a progress dialog while a process is running, I think I need something like asynktask.
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Click to expand...
Click to collapse
If you want the progress to.continue while doing a background task, your best and easy bet is to use async task. Create and show progress dialog in onPreExecute() and do the task in doInBackground() and close the progress in onPostExecute().
Sent from my GT-N7000 using xda app-developers app
vijai2011 said:
If you want the progress to.continue while doing a background task, your best and easy bet is to use async task. Create and show progress dialog in onPreExecute() and do the task in doInBackground() and close the progress in onPostExecute().
Sent from my GT-N7000 using xda app-developers app
Click to expand...
Click to collapse
Thank's a lot, this is what I mean ;D
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
vijai2011 said:
If you want the progress to.continue while doing a background task, your best and easy bet is to use async task. Create and show progress dialog in onPreExecute() and do the task in doInBackground() and close the progress in onPostExecute().
Sent from my GT-N7000 using xda app-developers app
Click to expand...
Click to collapse
... can you give me an example code of AsyncTask?, I can't find an understable explanation on Internet (for me)
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Here it is with progress dialog
Code:
class MyAsyncTask extends AsyncTask<Void, Void, Void> {
ProgressDialog prog;
[user=439709]@override[/user]
protected void onPreExecute() {
prog = new ProgressDialog(youractivity.this);
prog.setCancelable(false);
prog.setTitle("Title");
prog.setMessage("Message");
prog.setIndeterminate(true);
prog.show();
}
protected Void doInBackground(Void... params) {
//Your task to be done in Background while progress dialog is showing
return null;
}
[user=439709]@override[/user]
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
prog.dismiss(); //Progress is dismissed after background task is done
}
}
vijai2011 said:
Here it is with progress dialog
Code:
class MyAsyncTask extends AsyncTask<Void, Void, Void> {
ProgressDialog prog;
[user=439709]@override[/user]
protected void onPreExecute() {
prog = new ProgressDialog(youractivity.this);
prog.setCancelable(false);
prog.setTitle("Title");
prog.setMessage("Message");
prog.setIndeterminate(true);
prog.show();
}
protected Void doInBackground(Void... params) {
//Your task to be done in Background while progress dialog is showing
return null;
}
[user=439709]@override[/user]
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
prog.dismiss(); //Progress is dismissed after background task is done
}
}
Click to expand...
Click to collapse
Why it does not work?
Code:
public void End() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Es necesario reiniciar")
.setTitle("Instalacion satisfactoria!")
.setCancelable(false)
.setNegativeButton("Hacerlo mas tarde",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setPositiveButton("Reiniciar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
class MyAsyncTask extends AsyncTask<Void, Void, Void> {
ProgressDialog prog;
[user=439709]@override[/user]
protected void onPreExecute() {
prog = new ProgressDialog(FixWifiActivity.this);
prog.setCancelable(false);
prog.setTitle("Title");
prog.setMessage("Message");
prog.setIndeterminate(true);
prog.show();
}
protected Void doInBackground(Void... params) {
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
return null;
}
[user=439709]@override[/user]
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
prog.dismiss();
//Progress is dismissed after background task is done
}
AlertDialog alert = builder.create();
alert.show();
}
It has lots of errors
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
DannyGM16 said:
Why it does not work?
Code:
public void End() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Es necesario reiniciar")
.setTitle("Instalacion satisfactoria!")
.setCancelable(false)
.setNegativeButton("Hacerlo mas tarde",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setPositiveButton("Reiniciar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
class MyAsyncTask extends AsyncTask<Void, Void, Void> {
ProgressDialog prog;
[user=439709]@override[/user]
protected void onPreExecute() {
prog = new ProgressDialog(FixWifiActivity.this);
prog.setCancelable(false);
prog.setTitle("Title");
prog.setMessage("Message");
prog.setIndeterminate(true);
prog.show();
}
protected Void doInBackground(Void... params) {
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
return null;
}
[user=439709]@override[/user]
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
prog.dismiss();
//Progress is dismissed after background task is done
}
AlertDialog alert = builder.create();
alert.show();
}
It has lots of errors
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Click to expand...
Click to collapse
The ide will say of unimplemented method. Just highlight it and add unimplemented method and delete tye auto generated method. It will work then
Sent from my GT-N7000 using xda app-developers app
vijai2011 said:
The ide will say of unimplemented method. Just highlight it and add unimplemented method and delete tye auto generated method. It will work then
Sent from my GT-N7000 using xda app-developers app
Click to expand...
Click to collapse
Sorry, I'm Spanish, be more specific, with examples or something like this... I don't understand you
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
DannyGM16 said:
Sorry, I'm Spanish, be more specific, with examples or something like this... I don't understand you
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Click to expand...
Click to collapse
Take you mouse pointer over AsyncTask which would be underlined in red and click on "Add unimplemented method" or something like that. Then delete the methods having the comment "// TODO Auto-generated method stub". Then the error would be gone.
vijai2011 said:
Take you mouse pointer over AsyncTask which would be underlined in red and click on "Add unimplemented method" or something like that. Then delete the methods having the comment "// TODO Auto-generated method stub". Then the error would be gone.
Click to expand...
Click to collapse
I'm developing with my mobile xD
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
vijai2011 said:
Take you mouse pointer over AsyncTask which would be underlined in red and click on "Add unimplemented method" or something like that. Then delete the methods having the comment "// TODO Auto-generated method stub". Then the error would be gone.
Click to expand...
Click to collapse
Please, can you give me the code?
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
DannyGM16 said:
I'm developing with my mobile xD
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
Click to expand...
Click to collapse
With AIDE? Long-click on the code with the red mark below. Then click the first entry (something like "fix"). Select "add unimplemented methods".
That's it.
nikwen said:
With AIDE? Long-click on the code with the red mark below. Then click the first entry (something like "fix"). Select "add unimplemented methods".
That's it.
Click to expand...
Click to collapse
FU** It doesn't appear :'(
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
nikwen said:
With AIDE? Long-click on the code with the red mark below. Then click the first entry (something like "fix"). Select "add unimplemented methods".
That's it.
Click to expand...
Click to collapse
Code:
public void onClick(DialogInterface dialog, int id) {}
// metodo que se debe implementar
private class PlantFiles extends AsyncTask {
protected Boolean doInBackground(Void... arg0) {
try
{
comando();
}
catch (InterruptedException e)
{}
catch (IOException e)
{}
return null;
}
private void comando() throws IOException, InterruptedException
{
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
}
protected void onPostExecute(Boolean result){
pd.cancel();
}
protected void onPreExecute(Boolean result){
pd = ProgressDialog.show(FixWifiActivity.this, "Wait", "Loading...", true);
}
}});
AlertDialog alert = builder.create();
alert.show();
}
}
The code is correct but It doesn't work, can you fix it?
Enviado desde mi Galaxy Mini Plus 4G usando Tapatalk 2
could not find any version that matches com.android.support:appcompat-v7:+
How can i resolve this problem ?
Zeytin said:
could not find any version that matches com.android.support:appcompat-v7:+
How can i resolve this problem ?
Click to expand...
Click to collapse
Could you please post your whole build.gradle file?
What is the exact error message Android Studio shows you?
The project was written in the AndroidStudio (Windows). In the house, I opened a this project (Ubuntu).
Error when import project in Android studio:
Execution failed for task ':cards territoryrepareComAndroidSupportAppcompatV71900Library'.
> Could not expand ZIP '/home/dimoshka/android-studio/sdk/extras/android/m2repository/com/android/support/appcompat-v7/19.0.0/appcompat-v7-19.0.0.aar'.
Click to expand...
Click to collapse
build.gradle
Code:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
maven {
url "......bugsense.....gradle/"
}
}
android {
compileSdkVersion 17
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile "com.bugsense.trace:bugsense:3.6"
}
What could be the problem? The right to a directory entry with SDK there.
MULTI-GERRIT SCRIPT
This script removes the hassle of trying to remember how to push different patches to different gerrits for different ROMS.
This script IS in BETA for the time being.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
* Many teams already in place
AOKP
Carbon
Chameleon-OS
CyanogenMod
Dirty-Unicorns
Gummy
Omni
Paranoid-Android
PAC-Man
Vanir
Click to expand...
Click to collapse
* Easy to use
With commits you can:
Push them to a gerrit
Amend them
Change authors of the commit(s)
Find you SSH key
Click to expand...
Click to collapse
These features are all explained right below
Click to expand...
Click to collapse
Explanation of Features
setup/-su --- This is the option to run the initial setup again should you need to for some reason
team/-nt --- This allows you to change the gerrit that you are going to push to (CyanogenMod, PAC, Vanir, etc)
add+push/-ap --- This brings you through the process of adding a Change-ID if needed, then adding and pushing the files (git add -A, git commit -a, etc)
amend/-am --- This allows you to make changes to a commit that you have already pushed (aka, a patchset)
author/-au --- This allows you to change the author of the commit to help keep the correct commit history
name/-n --- This allows you to change the gerrit username you are using when pushing commits
push/-p --- This allows you to just push the changes to gerrit if that is all you need to do
sshkey/-ssh --- For those of you who don't know your ssh key and still need to put it into your gerrit account, this will open/create an ssh key that you can add to gerrit to be able to push
update/-u --- This will allow the script to check for a new version and update itself automatically if able to
Click to expand...
Click to collapse
Explanation of ADVANCED Features
WARNING: These options are only for people who know what they are doing and can fix it, should it break
addgerrit/-ag --- This allows you to add your own gerrit to push to, should we have missed one
force/-uf --- This will force the script to download a new version of itself and update
safety/-sa --- This will turn off (most of) the questions that are there to help prevent accidental pushing to wrong branches, etc
Click to expand...
Click to collapse
Code:
* Everything should be working
Right click on link and click "Save link as"
Save script
Create folder in home directory called "bin" - ex: home/goldflame09/bin
Execute in terminal: chmod a+x ~/bin/universal-review
Some of you may need to either reboot or logout here in order for script to be recognized
Run script by executing: universal-review
Follow promts
Enjoy!!
Script: http://pac-rom.com/downloads/gerritpush/universal-review
Click to expand...
Click to collapse
Open terminal
Execute: universal-review -u
Follow promts and wait
Enjoy the updated version
Click to expand...
Click to collapse
Thanks to:
[MENTION]@Papa Smurf151[/MENTION]
[MENTION]@soupmagnet[/MENTION]
[MENTION]@wedgess[/MENTION]
[MENTION]@pvyParts[/MENTION]
Click to expand...
Click to collapse
XDA:DevDB Information
Multi-Gerrit, a Tool/Utility for the Android General
Contributors
goldflame09, Papa Smurf151
Version Information
Status: Beta
Current Beta Version: 1
Beta Release Date: 2013-11-16
Created 2013-11-17
Last Updated 2013-11-16
Reserved
CHANGELOG:
11/16: First release
11/17: Fixed infinite loop when changing safety checks
Click to expand...
Click to collapse
Reserved
Been waiting days for use to be able to release this. Glad to have worked on this with you, pvyparts, soupmagnet, and others.
Great idea! Thank you dev for adding Vanir!
Same here! Great job guys!! Really means a lot to have DU added on to a list with some of the big name ROMs out there
Will spread the word on this for sure!!
For anyone that wishes to reshare this on G+ and help get the word out
https://plus.google.com/+Pac-rom/posts/9qUZRyHfFo5
Well, this didn't take long, but there is now a new version up
11/17:
Fix infinite loop when changing safety checks
Enjoy
Perfect tool for slow folks like me! Thanks