k9-mail with public folder support ( root namespace) - Android Apps and Games

hi,
here i attach the latest k9-mail, which i compiled (thanks to cketti), and where the namespace is fixed,so, that user can also access to folders, which are on /
(because the nold k9-mail - does use on empty namespace - automatically use from NAMESPACEcmd the first in the list, which is normally always: /INBOX
so, user can'T access to a public folder.
til my dirty hack (patch) will be in GIT -> i upload here the version.
it is called "k9-mail v4.102 camel-hack"
.) Fixed creation of store URIs when a "path" was used. (done by cketti on 29.11.2011)
.) Fix for empty IMAP Folder Prefix (with Prefix=*, then it will use real empty Prefix. Because if totally empty, then it will use the first namespace - mostly INBOX)
(it is based on GIT - from 29.11.2011)
if you want to use the "/"(root) namespace, then you must insert a "*" (without ") on IMAP Folder Prefix
this can be set in -> account settings ->retrieve message -> incomming mail server -> IMAP Folder Frefix
PLS: after changing IMAP Folder Prefix to *, please adjust your settings for your folder
this thread is related to http://code.google.com/p/k9mail/issues/detail?id=1992 and several others which are "namespace" or "shared folder" or public folder related. you will find a lot of threads about this issue.
INSTALL: sometimes it could happen, that you can't install it over previous installed versions:
this is a known issue of different k9-mail versions.
1.) please backup (titanium backup) and export (in k9-mail on account view") your settings.
2.) uninstall k9-mail
3.) install my attached version.
4.) restore your k9 settings -> using titanium backup -> find k9-mail -> restore "only data"
(or you can import your previous saved k9-mail settings)
- -- -- - - -- - - -- -
now, i hope that cketti will add my patch to GIT.
the patch is:
Code:
ImapStore.java
line 573
} else {
int prefixLength = getCombinedPrefix().length();
- if (prefixLength > 0) {
+ if (prefixLength > -1) { //camel: set to -1 (orig=0), to get all folders from "", too
// Strip prefix from the folder name
ImapStore.java
line 2246
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "NAMESPACE = " + hasCapability(CAPABILITY_NAMESPACE)
+ ", mPathPrefix = " + mSettings.getPathPrefix());
- if (mSettings.getPathPrefix() == null) {
+ if ((mSettings.getPathPrefix() == null) || (mSettings.getPathPrefix().equals("*"))) { // camel: to handle auto namespace and special case *
if (hasCapability(CAPABILITY_NAMESPACE)) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "mPathPrefix is unset and server has NAMESPACE capability");
List<ImapResponse> namespaceResponses =
executeSimpleCommand(COMMAND_NAMESPACE);
for (ImapResponse response : namespaceResponses) {
ImapStore.java
line 2268
if (firstNamespace != null && firstNamespace instanceof ImapList) {
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "Got first personal namespaces: " + firstNamespace);
bracketed = (ImapList)firstNamespace;
+ if (mSettings.getPathPrefix() == null) { // camel:case1: if empty, use namespace first NS
mSettings.setPathPrefix(bracketed.getString(0));
+ } else { // camel:case2: if *, then use empty path prefix
+ mSettings.setPathPrefix("");
+ }
mSettings.setPathDelimeter(bracketed.getString(1));
mSettings.setCombinedPrefix(null);
if (K9.DEBUG)
cu camel

Thank, you.
Works nice for me with shared folders on cyrus-imap.
Zaptac

Saw this because I have starred K9 ticket about shared folders (in)abilities. Just want to drop thanks for this, although I might wait for week or two before I try it to see if the K9 maintainer wil finally incorporate this into it.

vkrivokuca said:
Saw this because I have starred K9 ticket about shared folders (in)abilities. Just want to drop thanks for this, although I might wait for week or two before I try it to see if the K9 maintainer wil finally incorporate this into it.
Click to expand...
Click to collapse
well, i added the patch and the small changes (see on first posting)
there is nothing special (also patch from cketti is inside,where he fixed to import settings, where PREFIX was used (because there was a bug)
if cketti, will add it ... well, we will see.
here was always the discussio, that K9mail does only support 1 namespace. this means, if you ask your server via namespace cmd (see rfc3501), then you will get back the namespaces - like:
[[INBOX, /] [user, /] [PUBLIC-FOLDER /] [SHARED-FODLER]...]
and k9mail does:
if prefix is empty, then load namespace and use first field for IMAP PREFIX (second value is the delimiter, which can also be different)
so, the beautiful solution would be, to load from every namespace the folders into K9-Mail. But there is only 1 load for folders (LIST, SELECT, change to folder structure, etc..), and this would be very very complicated to load all of them ...
(this is also not possible in thunderbird or outlook or whatever, so - in my mind, i'm sure, that toload multiple namespaces into k9-mail doesn't make senseand wouldbe very complicated.
in my mind:
with the new method, we must only inform, user on the new PREFIX option "*", then users can load the whole namespace via * from server (this could be added to the prefix hint field in IMAP PREFIX field and will be shown if it is empty)
cu camel

please also, help to give me feedback, otherwise it will not implement in future versions.
we must be sure, that it is working lfine for all (because there are ~700k user, which are using k9-mail)
cu camel

Related

[5/03] WPA-Enterprise WORKING for UT, UNSW, Georgia Tech

At this time, my courseload is way too high for me to do this. I also formatted and lost my sourcecode so I would have to write it from scratch. Sorry!
http://www.4shared.com/file/103246844/247a67c/WPA_Enterprise.html
Look below for instructions to request your school
Root, of course, is required.
The only other things this program needs is for the user to input their username and password as well as copy the security certificate to their SDcard as well as copying the security file to the SDcard. The program takes care of the rest.
I can modify my program to allow other people to connect to WPA Enterprise places in their area. If there is interest in this, let me know and I would be happy to upload versions of my program that allows others to connect.
Donations are always enjoyed
For UT Students:
1. Copy cacerts.pem to your SDCard. Make sure its named cacerts.pem NOT cacerts.pem or anything else similar. The program is CASE SENSITIVE. Make sure to UNMOUNT your sdcard from the computer
2. Run the program and click always to the superuser prompt (if you have it installed)
3. Input your information.
4. Click Save
5. Click Install
6. Click Reboot
If you ever need to revert, just open the program and click undo!
For UNSW Students:
1. Run the program and click always to the superuser prompt (if you have it installed)
3. Input your password (leave username blank)
4. Click Save
5. Click Install
6. Click Reboot
If you ever need to revert, just open the program and click undo!
For Georgia Tech Students
1. Copy Equifax_Secure_CA.pem to your SDCard. Make sure its named Equifax_Secure_CA.pem. The program is CASE SENSITIVE. Make sure to UNMOUNT your sdcard from the computer
2. Run the program and click always to the superuser prompt (if you have it installed)
3. Input your information.
4. Click Save
5. Click Install
6. Click Reboot
If you ever need to revert, just open the program and click undo!
If anyone else wants it, link me to a page like this one and it will give me an example config.
Enjoy!
persiansown said:
I'm putting the finishing touches on my program that allows students that go to the University of Texas to connect to the WPA-Enterprise network here.
Root, of course, is required.
The only other things this program needs is for the user to input their username and password as well as copy the security certificate to their SDcard. The program takes care of the rest.
I can modify my program to allow other people to connect to WPA Enterprise places in their area. If there is interest in this, let me know and I would be happy to upload versions of my program that allows others to connect.
BTW, It definitely does work, I was able to connect to restricted.utexas.edu on my phone and browse the web through it.
Click to expand...
Click to collapse
Thats good news - I am interested - if this works, i'd be finally able to use it on my uni network.
btw - im on adb 1.5 official.
For those who are in a hurry:
http://forum.xda-developers.com/archive/index.php/t-450915.html
Cool Hook EM
Sorry I haven't uploaded the APK yet. I've been really busy with school and the like.
I need to put in a couple more lines so no one screws up their wifi. Expect it soon though
Fellow longhorn says "thanks in advance"
Sounds good, can finally connect to wifi @ my university
Program Released!
need a config pls
thanks alot for this.
here's a link for my uni : http://www.port.ac.uk/special/is/mobilemedia/broadband/wirelessoncampus/ -> its got the config details.
my uni operates on both wpa/wpa2 and the auth is peap, mschapv2
the cer certificate is on the windows xp part on the above link.
ive converted my .cer to .pem through openssl, so atleast one step is complete.
any help pls? thanks.
grippa said:
thanks alot for this.
here's a link for my uni : http://www.port.ac.uk/special/is/mobilemedia/broadband/wirelessoncampus/ -> its got the config details.
my uni operates on both wpa/wpa2 and the auth is peap, mschapv2
the cer certificate is on the windows xp part on the above link.
ive converted my .cer to .pem through openssl, so atleast one step is complete.
any help pls? thanks.
Click to expand...
Click to collapse
I can try that. Im not sure, but Ill try to wing it for you. Ill send you a PM when its uploaded.
If you could try to do the same for these settings that would be awesome =]
http://www.it.unsw.edu.au/services/uniwide/mobile_devices.html
smurphete said:
If you could try to do the same for these settings that would be awesome =]
http://www.it.unsw.edu.au/services/uniwide/mobile_devices.html
Click to expand...
Click to collapse
We've got the same settings here for WPA-Enterprise, only the SSID is "OpenWLAN". (WPA-TKIP / WPA2-AES (Enterprise) & EAP (PEAP and MS-CHAPv2))
Do you think there is a way to do this?
Please post the source. I suggest that other UT students refrain from using this application until then, due to the ridiculously high abuse potential of an app that elevates to root, and even worse, one that you enter EID + password in.
The normal restrictions on network access can be sidestepped. Your EID and password could easily be harvested. Don't run apps like this until the source is available and someone reputable looks at it.
I posted UT Austin specific instructions back in November. If you want access at UT but don't like to gamble, feel free to give them a try. They're a bit dated with respect to gaining root.
http://forum.xda-developers.com/showthread.php?t=450915
I'll add also that the instructions will probably work at any location using WPA Enterprise auth - anything that wpa_supplicant supports. There are several examples in my thread of people getting it to work at their school/workplace. You can either create the configuration file yourself by looking at the Windows/Mac/whatever instructions made available to you, or you may try contacting the local IT dept.
package com.test.login;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
public class Login extends Activity {
// Declare our Views, so we can access them later
private EditText etUsername;
private EditText etPassword;
private Button btnLogin;
private Button btnInstall;
private Button btnUndo;
private Button btnRestart;
private String username;
private String password;
private String securityfilename = "cacerts.pem";
private boolean copied = false;
/** Called when the activity is first created. */
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
command("cp /data/misc/wifi/wpa_supplicant.conf /sdcard/wpa_supplicant.conf");
command("cp /data/misc/wifi/wpa_supplicant.conf /sdcard/wpa_supplicant.conf.bac");
super.onCreate(savedInstanceState);
// Set Activity Layout
setContentView(R.layout.main);
// Get the EditText and Button References
etUsername = (EditText)findViewById(R.id.username);
etPassword = (EditText)findViewById(R.id.password);
btnLogin = (Button)findViewById(R.id.login_button);
btnInstall = (Button)findViewById(R.id.install_button);
btnRestart = (Button)findViewById(R.id.restart_button);
btnUndo = (Button)findViewById(R.id.undo_button);
// Spinner array
final Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, R.array.locations, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
action("WARNING!","If you have superuser installed, you MUST click ALWAYS before continuing.\n \nOtherwise I'm not sure what may happen\n\nMake sure your Security Certificate is on your SDcard");
// Set Click Listener
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Check Login
username = etUsername.getText().toString();
password = etPassword.getText().toString();
action("Step 1 Complete","Input Successful\nIf phone is in landscape, change to portrait and click again ");
String place = (String) s.getSelectedItem();
inputvalues (username, password, place);
}
});
btnInstall.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
command ("cp /sdcard/" + securityfilename + " /data/misc/wifi/" + securityfilename);
command ("cp /sdcard/wpa_supplicant.conf" + " /data/misc/wifi/wpa_supplicant.conf");
command ("chmod 666 /data/misc/wifi/wpa_supplicant.conf");
command ("chmod 444 /data/misc/wifi/cacerts.pem");
copied = true;
try {
Thread.sleep(2500);
}
catch(InterruptedException e) {}
action("Step 2 Complete","Config Saved Successfly");
}
});
btnRestart.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(copied)
command ("reboot");
}
});
btnUndo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
command ("cp /sdcard/wpa_supplicant.conf.bac" + " /data/misc/wifi/wpa_supplicant.conf");
}
});
}
public void command (String inputcommand)
{
Process process = null;
DataOutputStream os = null;
try
{
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(inputcommand);
os.flush();
os.close();
}
catch (Exception e)
{
return;
}
finally
{
try
{
if (os !=null)
{
os.close();
}
}
catch (Exception e) {}
}
}
public void inputvalues (String usrname, String pswrd, String location)
{
if (location=="University of Texas at Austin");
{
try
{
BufferedWriter writer = new BufferedWriter(new FileWriter("/sdcard/wpa_supplicant.conf", true));
writer.newLine();
writer.write("fast_reauth=0");
writer.newLine();
writer.write("network={");
writer.newLine();
writer.write("\t ssid=\"restricted.utexas.edu\"");
writer.newLine();
writer.write("\t key_mgmt=WPA-EAP");
writer.newLine();
writer.write("\t eap=TTLS");
writer.newLine();
writer.write("\t ca_cert=\"/data/misc/wifi/" + securityfilename + "\"");
writer.newLine();
writer.write("subject_match=\"CN=restricted.utexas.edu\"");
writer.newLine();
writer.write("\t anonymous_identity=\"anonymous\"");
writer.newLine();
writer.write("\t identity=\"" + usrname + "\"");
writer.newLine();
writer.write("\t password=\"" + pswrd + "\"");
writer.newLine();
writer.write("\t phase2=\"auth=MSCHAPV2\"");
writer.newLine();
writer.write("}");
writer.newLine();
writer.newLine();
writer.flush();
writer.close();
}
catch(FileNotFoundException ex){}
catch(IOException ioe){}
}
}
public void action (String step, String title)
{
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(step);
alert.setMessage(title);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
//cancel
}
});
alert.show();
}
}
Click to expand...
Click to collapse
Here is my source. There is an XML portion that takes care of the interface.
To be truthful, I'm kind of embarrassed of the code because I haven't touched Java since highschool. There is nothing wrong with this application, and nothing nefarious. To be honest, I wouldn't know how to do something like that if I wanted since I would have to delve into the commands.
If you have any suggestions for my code, I would be happy to hear them.
I took up this application as a side product just to see if my knowledge of linux was strong enough (I used linux on my netbook for a while before switching to windows 7) and once I got it working I wanted to share it with the community that has given me so much on both my current phone and previous ones.
Anyway, to all the people in this thread who are requesting stuff:
My birthday is today and my girlfriend came up to UT to celebrate with me. She won't be leaving until Sunday so.... I won't be working on it until Sunday. Bear with me though, I will get it up for you guys if I can (again, I pretty much suck. But now that the framework is down, I think I know what to do)
Smurfette, I took a look there and I'm pretty sure I can do it for you
Georgia Institute of Technology Pilot WPA Program
http://www.lawn.gatech.edu/help/gtwpa/
These are the instructions about signing on to WPA at my university. I will look at modifying the source myself, but I don't have time either at the moment. Just curious--how many other GT students are using XDA-developers to mod their Dream??
So far I am sure I can do it for ellingthepirate and smurphete. I found example configurations for those two. I'm not sure about N23 or the guy on the other page yet. Again, I won't be able to update the app until sunday night (central time) at the earliest.
Will this eventually work with the *.cer certificates?
Hi Persiansown,
I am working on something similar. Can you tell me how did you get permission to create/modify wpa_supplicant.conf programatically?
THANK YOU SO MUCH!!
zhang42 said:
Hi Persiansown,
I am working on something similar. Can you tell me how did you get permission to create/modify wpa_supplicant.conf programatically?
THANK YOU SO MUCH!!
Click to expand...
Click to collapse
Never mind! I've figured it out!
Updated for University of South Wales and Georgia Tech

[Q] SeekBar problem in Settings.apk source

I'm stuck. I am building a custom Settings.apk for a new tablet and I've run across an error I can't find.
Any dialog that displays a SeekBar or variation simply FC's with a null pointer exception. I have a reference source tree that is a virgin copy from the android git. If I compile the stock Settings.apk, it does the same thing at the same places as my custom version.
The error occurs in the BrightnessPreference.java and the RingerVolumePreference.java files any time the dialog containing a SeekBar or Volumizer tries to display.
Here's an example of the code:
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
mSeekBar = getSeekBar(view);
mSeekBar.setMax(MAXIMUM_BACKLIGHT - mMinBrightness); <-- errors here
It errors at setMax with a null pointer error, like the setMax method doesn't exist. My build environment seems fine. Everything I've built runs on the target devices, but this one has me stumped. Has anyone else tried building a Settings.apk lately, and does it display the volume (in sound) and brightness (in Display) dialogs?
BTW, the target is Froyo
Thanks,
--- Jem
Are you sure the mMinBrightness variable is defined? BrightnessPreference.java as shown here instead uses MINIMUM_BACKLIGHT and is defined as:
Code:
private static final int MINIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_DIM + 10;
It is then used to set the seekbar max:
Code:
mSeekBar.setMax(MAXIMUM_BACKLIGHT - MINIMUM_BACKLIGHT);
You can also look at the onBindDialogView in RingerVolumePreference.java here. If you want to check whether the java files change from the version I linked(2.2.1 Froyo), just use the arrows on either side of the currently listed version.
I appreciate the response. Yes it is defined and initialized earlier as referenced below.
=== Code ===
private int mMinBrightness;
private boolean mAutomaticAvailable;
// Backlight range is from 0 - 255. Need to make sure that user
// doesn't set the backlight to 0 and get stuck
private static final int MINIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_DIM + 10;
private static final int MAXIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_ON;
public BrightnessPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mAutomaticAvailable = context.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
setDialogLayoutResource(R.layout.preference_dialog_brightness);
setDialogIcon(R.drawable.ic_settings_display);
mMinBrightness = MINIMUM_BACKLIGHT;
if (Settings.System.getInt(context.getContentResolver(),
Settings.System.LIGHT_SENSOR_CUSTOM, 0) != 0) {
mMinBrightness = Settings.System.getInt(context.getContentResolver(),
Settings.System.LIGHT_SCREEN_DIM, mMinBrightness);
}
}
=== code ===
Thanks,
--- Jem
It might be useful to rule out an issue with mMinBrightness not getting set or getting set incorrectly by either replacing it with MINIMUM_BACKLIGHT in the setMax line or using a toast message to display the value of mMinBrightness before setMax. If that doesn't reveal anything, could you paste the relevant logcat output for the error/fc and also upload your BrightnessPreference.java file somewhere so it could be downloaded.
I saved the dir's with my modified package and blew away the entire repo structure. I then reloaded the official Android tree from kernel.org. I have compiled the Settings.apk app ALL STOCK, and I get the same errors in the brightness and volume areas. A copy of the brightnesspreference.java and a log screenshot of the error tracking can be found at:
mlsoft dot sytes dot net/brightness.zip (I can't post the direct link)
The only change in the error is the line number (same call though).
At this point, I am wondering if anyone can build the Settings.apk from the repo and get it to display a seekbar or variant in brightness or volume settings using 2.2.1 (froyo). I am comfortable at this point thinking that it is in the tree structure and not my build environment. At least I have a place to hunt if you can reproduce the error on your end.
I really appreciate your help.
--- Jem
android:id="@*android
Yeah, same thing happened to me and I found answer.
I hope this might help.
You will find that two xml files using "@*android".
"It gives access to internal resources for platform apps.
It is NOT safe to build apps with such declarations unless you are building a bundled app within a full system image."
- from stackoverflow
"What is the purpose of the star in the ID string?"
Sorry that I can not post URL. I'm new user.
Sorry about not yet having built and tested the Settings.apk on my end but I haven't found the time to do so yet. Your issue could very well be what You Kim posted about and I'm sure I wouldn't have noticed that for awhile if at all. Here's the link to the stack overflow topic You Kim referenced. The two xml files in the Settings package this occurs in are res/layout/preference_dialog_brightness.xml and res/layout/preference_dialog_ringervolume.xml. That part looks like this:
Code:
<!-- In brightness layout -->
<[COLOR="Red"]SeekBar android:id="@*android:id/seekbar"[/COLOR]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dip" />
<!-- In ringervolume layout -->
<!-- Used for the ring volume. This is what the superclass VolumePreference uses. -->
<[COLOR="red"]SeekBar android:id="@*android:id/seekbar"[/COLOR]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:paddingLeft="20dip"
android:paddingRight="20dip" />
Thank you both. I have been through those files more than once and didn't notice the declarations. Outstanding work guys. I'm off to edit/recompile/test.
Thanks again,
--- Jem
Unfortunately, these changes didn't stop the null pounter errors. Something, somewhere HAS to be uninitialized, but damned if I can find it in the absseekbar, progressbar, or any other class in the seekbar hierarchy. I even tried setting a value of 255 in setMax to rule out variable problems, but that produces the same error at the same line.
I know there is a fix, Settings works on millions of Android devices, so it has to be something stupid I'm overlooking.
--- Jem
Well, it's almost 3am, but I fixed the problem in the brightness preference. SeekBarPreference handles the getSeekBar function, but it doesn't work as expected.
It assigns a static system res ID that obviously doesn't work as intended. So, I overrode the routine just above the call to onBindDialogView. Here is the routine in the seekbarpreference file:
(at sign)Override
protected static SeekBar getSeekBar(View dialogView) {
return (SeekBar) dialogView.findViewById(com.android.internal.R.id.seekbar);
}
Overridden in the brightnes preference file to this:
(at sign)Override
protected static SeekBar getSeekBar(View dialogView) {
return (SeekBar) dialogView.findViewById(R.id.seekbar);
}
I'll go back and write the original to accept a res ID as an argument later. For now at least the brightness control works. Tomorrow I'll go after the volume controls.
--- Jem

[Q] Need help to populate a listview from external source

I'm pretty new to java and somewhat new to android and I've been looking everywhere for the past 3 or 4 days but cant seem to find the answer to my question. I'm making an app that is pretty simple and has only one real main function and that is to pull movie names, release dates, and the movie's format (dvd, blu-ray etc) into the app automatically from a very simple file that I will host on my server.
Now I I'm currently able to input the needed information manually via a base-adapter and a strings file within each months activity but I want to have the ability to push the information remotely which will then give my app (and myself) the ability to update the information as well as to place it into the 3 line listview format that I've already established.
Now I've been reading about Simple:XML, gson, SAX, etc but seeing as the information is just 3 small lines of text (again just the movie name, date and format which doesn't use much space and will be using the same string format for all 12 months) my question is what would be the best route as to the format of the file (i.e. xml, json, plain text, etc) and how would I go about getting this information into my app on the fly? I've included some code snippets below in the hopes they will make my question a little more clear.
I've posted this on several other forums and android dev sites and nobody seems to be able to give me some guidance or simply will not reply at all. I cannot continue on my app until I'm able to figure this out and seeing as it is completed aside from this problem it is becoming a very frustrating experience. I'm hopeful that someone here will be able to give my some help out. Thank you in advance.
The string for each result
Code:
public class SearchResults {
private String Name = "";
private String Date = "";
private String Format = "";
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getDate() {
return Date;
}
public void setDate(String Date) {
this.Date = Date;
}
public String getFormat() {
return Format;
}
public void setFormat(String Format) {
this.Format = Format;
}
This below is where the actual list-view is populated and shown. Each new search result creates a three line text-view.
Code:
private ArrayList<SearchResults> GetSearchResults(){
ArrayList<SearchResults> results = new ArrayList<SearchResults>();
SearchResults sr1 = new SearchResults();
sr1.setName("Movie #1");
sr1.setDate("July 24th");
sr1.setFormat("DVD, Blu-Ray");
results.add(sr1);
sr1 = new SearchResults();
sr1.setName("Movie #2");
sr1.seDate("July 19th");
sr1.setFormat("DVD, Blu-Ray, Digital");
results.add(sr1);
return results;
}
Can anybody help me with this please?

[Q] In need of dslreports trunk outtage saving script (pbxes)

Hello,
If anyone has the dslreports.com script for:
Saving a random setting on Pbxes.org when there's a trunk outage notification (free account) ,
I would highly appreciate it.
The above website is unavailable currently and am in need of the script so I can use my GV + Callback + Sipdroid. For reference, it was a simple (either JS or VB) script which saved a random setting whenever there was a trunk outage.
Or if there are any other suggestions for someone to route calls pretty much the same way for android 1.6 I would highly appreciate it as well.
Thank you
Also, a new question,
would anyone happen to know if at this date 4/23/12, Verizon charges or back charges people for using Google voice + callback for free calls as well?
thank you for any help
edited in question
..
I created this vbscript a few years ago for the same reason. Works well. I have it set up as a Rule in Outlook, so whenever I get a trunk outage email from PBXes, it runs this script automatically.
dslreports.com/forum/r24908015-PBXes-free-acount-trunk-outtage-quick-fix
I've pasted the script here just in case the dsl reports post gets removed:
Code:
'###########################################
'## PBXes Trunk Outtage Recovery
'## for Free Users
'##
'## Author: atomicrabbit ([email protected])
'## Date: 2010.10.08
'###########################################
'Edit the following variables appropriately
'------- START EDITING HERE ... DO NOT TOUCH ANYTHING BELOW -------
'Setting Page
' Set this to one of the settigs pages of PBXes
pbxes_settingPage = "https://www4.pbxes.com/config.php?display=extensions&extdisplay=100"
'Form Name
' Set this to the form name on the settings page specified above.
' It MUST be relative to the form on the page specified above
pbxes_formName = "addNew"
'PBXes Login Info
pbxes_username = "your_username" 'Your PBXes.com username
pbxes_password = "your_password" 'Your PBXes.com passowrd
'IE Window Visibility
' True - IE window will be visible while processing the code
' False - IE window will be hidden and run the code in the background
pbxes_windowVisible = False
'Browser Timeout
' Set max timeout for browser responsiveness (in seconds)
' Default: 7
pbxes_timeout = 7
'------- STOP EDITING HERE ... DO NOT TOUCH ANYTHING BELOW -------
pbxes_applySettings = pbxes_settingPage + "&clk_reload=true"
pbxes_timeout = pbxes_timeout * 5 'because the iterations are 200ms
pbxes_tCount = 1
'Create IE object
Set objIE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
'Go to PBXes.com Extensions page
objIE.Navigate pbxes_settingPage
objIE.Visible = pbxes_windowVisible
Wscript.Sleep 1000
'Check if not logged in
if not objIE.Document.Forms("login") is nothing then
' Login to PBXes if you're not already
objIE.Document.All.Item("username").Value = pbxes_username
objIE.Document.All.Item("password").Value = pbxes_password
objIE.Document.All.Item("remember").checked = "false"
objIE.Document.All.Item("btnSubmit").click
Wscript.Sleep 2000
'Go to settings page
objIE.Navigate pbxes_settingPage
'Wait for page to load
Do
Wscript.Sleep 200
pbxes_tCount = pbxes_tCount + 1
Loop While objIE.Document.Forms(pbxes_formName) is nothing AND pbxes_tCount < pbxes_timeout
end if
if pbxes_tCount >= pbxes_timeout AND objIE.Document.Forms(pbxes_formName) is nothing Then
MsgBox "Browser timeout. Try running thescript again.", vbOkOnly, "PBXes Trunk Outtage"
'exit script
Elseif not objIE.Document.Forms(pbxes_formName) is nothing Then
'Submit form
call objIE.Document.Forms(pbxes_formName).elements("Submit").click
Wscript.Sleep 2000
'Apply the changes (red bar at top)
objIE.Navigate pbxes_applySettings
Wscript.Sleep 2000
'Close IE
objIE.Quit
MsgBox "Recovered from trunk outtage!", vbOkOnly, "PBXes Trunk Outtage"
Else
MsgBox "Could not find '" & pbxes_formName & "' form on '" & pbxes_settingPage & "'.", vbOkOnly, "PBXes Trunk Outtage"
'exit script
End if
'Clear variables
Set objIE = Nothing
Set pbxes_settingPage = Nothing
Set pbxes_applySettings = Nothing
Set pbxes_username = Nothing
Set pbxes_password = Nothing
Set pbxes_windowVisible = Nothing
Set pbxes_timeout= Nothing
Set pbxes_tCount= Nothing
Wscript.quit
I actually found the script before this but still Thank You for the script as it's been helpful, although I don't know why I seem to receive "false outtage" e-mails in the sense that calls still seem to be routed with not much interruption if any, what's with that?
Thank you!!

[GUIDE] Development and remote installation of Java service for the Android Devices

Author: Apriorit (Device Team)
Permanent link: www(dot)apriorit(dot)com/our-company/dev-blog/130-development-for-android
In this article I’ve described:
• How to develop simple Java service for the Android Devices;
• How to communicate with a service from the other processes and a remote PC;
• How to install and start the service remotely from the PC.
1. Java Service Development for the Android Devices
Services are long running background processes provided by Android. They could be used for background tasks execution. Tasks can be different: background calculations, backup procedures, internet communications, etc. Services can be started on the system requests and they can communicate with other processes using the Android IPC channels technology. The Android system can control the service lifecycle depending on the client requests, memory and CPU usage. Note that the service has lower priority than any process which is visible for the user.
Let’s develop the simple example service. It will show scheduled and requested notifications to user. Service should be managed using the service request, communicated from the simple Android Activity and from the PC.
First we need to install and prepare environment:
• Download and install latest Android SDK from the official web site http://developer.android.com);
• Download and install Eclipse IDE (http://www.eclipse.org/downloads/);
• Also we’ll need to install Android Development Tools (ADT) plug-in for Eclipse.
After the environment is prepared we can create Eclipse Android project. It will include sources, resources, generated files and the Android manifest.
1.1 Service class development
First of all we need to implement service class. It should be inherited from the android.app.Service (http://developer.android.com/reference/android/app/Service.html) base class. Each service class must have the corresponding <service> declaration in its package's manifest. Manifest declaration will be described later. Services, like the other application objects, run in the main thread of their hosting process. If you need to do some intensive work, you should do it in another thread.
In the service class we should implement abstract method onBind. Also we override some other methods:
onCreate(). It is called by the system when the service is created at the first time. Usually this method is used to initialize service resources. In our case the binder, task and timer objects are created. Also notification is send to the user and to the system log:
Code:
01.public void onCreate()
02.{
03. super.onCreate();
04. Log.d(LOG_TAG, "Creating service");
05. showNotification("Creating NotifyService");
06.
07. binder = new NotifyServiceBinder(handler, notificator);
08. task = new NotifyTask(handler, notificator);
09. timer = new Timer();
10.}
onStart(Intent intent, int startId). It is called by the system every time a client explicitly starts the service by calling startService(Intent), providing the arguments it requires and the unique integer token representing the start request. We can launch background threads, schedule tasks and perform other startup operations.
Code:
1.public void onStart(Intent intent, int startId)
2.{
3. super.onStart(intent, startId);
4. Log.d(LOG_TAG, "Starting service");
5. showNotification("Starting NotifyService");
6.
7. timer.scheduleAtFixedRate(task, Calendar.getInstance().getTime(), 30000);
8.}
onDestroy(). It is called by the system to notify a Service that it is no longer used and is being removed. Here we should perform all operations before service is stopped. In our case we will stop all scheduled timer tasks.
Code:
1.public void onDestroy()
2.{
3. super.onDestroy();
4. Log.d(LOG_TAG, "Stopping service");
5. showNotification("Stopping NotifyService");
6.
7. timer.cancel();
8.}
onBind(Intent intent). It will return the communication channel to the service. IBinder is the special base interface for a remotable object, the core part of a lightweight remote procedure call mechanism. This mechanism is designed for the high performance of in-process and cross-process calls. This interface describes the abstract protocol for interacting with a remotable object. The IBinder implementation will be described below.
Code:
1.public IBinder onBind(Intent intent)
2.{
3. Log.d(LOG_TAG, "Binding service");
4. return binder;
5.}
To send system log output we can use static methods of the android.util.Log class (http://developer.android.com/reference/android/util/Log.html). To browse system logs on PC you can use ADB utility command: adb logcat.
The notification feature is implemented in our service as the special runnable object. It could be used from the other threads and processes. The service class has method showNotification, which can display message to user using the Toast.makeText call. The runnable object also uses it:
Code:
01.public class NotificationRunnable implements Runnable
02.{
03. private String message = null;
04.
05. public void run()
06. {
07. if (null != message)
08. {
09. showNotification(message);
10. }
11. }
12.
13. public void setMessage(String message)
14. {
15. this.message = message;
16. }
17.}
Code will be executed in the service thread. To execute runnable method we can use the special object android.os.Handler. There are two main uses for the Handler: to schedule messages and runnables to be executed as some point in the future; and to place an action to be performed on a different thread than your own. Each Handler instance is associated with a single thread and that thread's message queue. To show notification we should set message and call post() method of the Handler’s object.
1.2 IPC Service
Each application runs in its own process. Sometimes you need to pass objects between processes and call some service methods. These operations can be performed using IPC. On the Android platform, one process can not normally access the memory of another process. So they have to decompose their objects into primitives that can be understood by the operating system , and "marshall" the object across that boundary for developer.
The AIDL IPC mechanism is used in Android devices. It is interface-based, similar to COM or Corba, but is lighter . It uses a proxy class to pass values between the client and the implementation.
AIDL (Android Interface Definition Language) is an IDL language used to generate code that enables two processes on an Android-powered device to communicate using IPC. If you have the code in one process (for example, in Activity) that needs to call methods of the object in another process (for example, Service), you can use AIDL to generate code to marshall the parameters.
Service interface example showed below supports only one sendNotification call:
Code:
1.interface INotifyService
2.{
3.void sendNotification(String message);
4.}
The IBinder interface for a remotable object is used by clients to perform IPC. Client can communicate with the service by calling Context’s bindService(). The IBinder implementation could be retrieved from the onBind method. The INotifyService interface implementation is based on the android.os.Binder class (http://developer.android.com/reference/android/os/Binder.html):
Code:
01.public class NotifyServiceBinder extends Binder implements INotifyService
02.{
03. private Handler handler = null;
04. private NotificationRunnable notificator = null;
05.
06. public NotifyServiceBinder(Handler handler, NotificationRunnable notificator)
07. {
08. this.handler = handler;
09. this.notificator = notificator;
10. }
11.
12. public void sendNotification(String message)
13. {
14. if (null != notificator)
15. {
16. notificator.setMessage(message);
17. handler.post(notificator);
18. }
19. }
20.
21. public IBinder asBinder()
22. {
23. return this;
24. }
25.}
As it was described above, the notifications could be send using the Handler object’s post() method call. The NotificaionRunnable object is passed as the method’s parameter.
On the client side we can request IBinder object and work with it as with the INotifyService interface. To connect to the service the android.content.ServiceConnection interface implementation can be used. Two methods should be defined: onServiceConnected, onServiceDisconnected:
Code:
01.ServiceConnection conn = null;
02.…
03.conn = new ServiceConnection()
04.{
05. public void onServiceConnected(ComponentName name, IBinder service)
06. {
07. Log.d("NotifyTest", "onServiceConnected");
08. INotifyService s = (INotifyService) service;
09. try
10. {
11. s.sendNotification("Hello");
12. }
13. catch (RemoteException ex)
14. {
15. Log.d("NotifyTest", "Cannot send notification", ex);
16. }
17. }
18.
19. public void onServiceDisconnected(ComponentName name)
20. {
21. }
22.};
The bindService method can be called from the client Activity context to connect to the service:
1. Context.bindService(new Intent(this, NotifyService.class),
2.conn, Context.BIND_AUTO_CREATE);
The unbindService method can be called from the client Activity context to disconnect from the service:
1.Context.unbindService(conn);
1.3 Remote service control
Broadcasts are the way applications and system components can communicate. Also we can use broadcasts to control service from the PC. The messages are sent as Intents, and the system handles dispatching them, including starting receivers.
Intents can be broadcasted to BroadcastReceivers, allowing messaging between applications. By registering a BroadcastReceiver in application’s AndroidManifest.xml (using <receiver> tag) you can have your application’s receiver class started and called whenever someone sends you a broadcast. Activity Manager uses the IntentFilters, applications register to figure out which program should be used for a given broadcast.
Let’s develop the receiver that will start and stop notify service on request. The base class android.content.BroadcastReceiver should be used for these purposes (http://developer.android.com/reference/android/content/BroadcastReceiver.html):
Code:
01.public class ServiceBroadcastReceiver extends BroadcastReceiver
02.{
03.…
04. private static String START_ACTION = "NotifyServiceStart";
05. private static String STOP_ACTION = "NotifyServiceStop";
06.…
07. public void onReceive(Context context, Intent intent)
08. {
09. …
10. String action = intent.getAction();
11. if (START_ACTION.equalsIgnoreCase(action))
12. {
13. context.startService(new Intent(context, NotifyService.class));
14. }
15. else if (STOP_ACTION.equalsIgnoreCase(action))
16. {
17. context.stopService(new Intent(context, NotifyService.class));
18. }
19.
20. }
21.}
To send broadcast from the client application we use the Context.sendBroadcast call. I will describe how to use receiver and send broadcasts from the PC in chapter 2.
1.4 Android Manifest
Every application must have an AndroidManifest.xml file in its root directory. The manifest contains essential information about the application to the Android system, the system must have this information before it can run any of the application's code. The core components of an application (its activities, services, and broadcast receivers) are activated by intents. An intent is a bundle of information (an Intent object) describing a desired action — including the data to be acted upon, the category of component that should perform the action, and other pertinent instructions. Android locates an appropriate component to respond to the intent, starts the new instance of the component if one is needed, and passes it to the Intent object.
We should describe 2 components for our service:
• NotifyService class is described in the <service> tag. It will not start on intent. So the intent filtering is not needed.
• ServiceBroadcastReceived class is described in the <receiver> tag. For the broadcast receiver the intent filter is used to select system events:
Code:
01.<application android:icon="@drawable/icon" android:label="@string/app_name">
02.…
03. <service android:enabled="true" android:name=".NotifyService"
04.android:exported="true">
05. </service>
06. <receiver android:name="ServiceBroadcastReceiver">
07. <intent-filter>
08. <action android:name="NotifyServiceStart"></action>
09. <action android:name="NotifyServiceStop"></action>
10. </intent-filter>
11. </receiver>
12.…
2. Java service remote installation and start
2.1 Service installation
Services like the other applications for the Android platform can be installed from the special package with the .apk extension. Android package contains all required binary files and the manifest.
Before installing the service from the PC we should enable the USB Debugging option in the device Settings-Applications-Development menu and then connect device to PC via the USB.
On the PC side we will use the ADB utility which is available in the Android SDK tools directory. The ADB utility supports several optional command-line arguments that provide powerful features, such as copying files to and from the device. The shell command-line argument lets you connect to the phone itself and issue rudimentary shell commands.
We will use several commands:
• Remote shell command execution: adb shell <command> <arguments>
• File send operation: adb push <local path> <remote path>
• Package installation operation: adb install <package>.apk
I’ll describe the package installation process in details. It consists of several steps which are performed by the ADB utility install command:
• First of all the .apk package file should be copied to the device. The ADB utility connects to the device and has limited “shell” user privileges. So almost all file system directories are write-protected for it. The /data/local/tmp directory is used as the temporary storage for package files. To copy package to the device use the command:
adb push NotifyService.apk /data/local/tmp
• Package installation. ADB utility uses special shell command to perform this operation. The “pm” (Package Manager?) utility is present on the Android devices. It supports several command line parameters which are described in the Appendix I. To install the package by yourself execute the remote shell command:
adb shell pm install /data/local/tmp/NotifyService.apk
• Cleanup. After the package is installed, ADB removes the temporary file stored in /data/local/tmp folder using the “rm” utility:
adb shell rm /data/local/tmp/NotifyService.apk.
• To uninstall package use the “pm” utility:
adb shell pm uninstall <package>
2.2 Remote service control
To be able to start and stop the NotifyService from the PC we can use the “am” (Activity Manager?) utility which is present on the Android device. The command line parameters are described in the Appendix II. The “am” utility can send system broadcast intents. Our service has the broadcast receiver which will be launched by the system request.
To start NotifyService we can execute remote shell command:
adb shell am broadcast –a NotifyServiceStart
To stop the NotifyService we can execute remote shell command:
adb shell am broadcast –a NotifyServiceStop
Note, that the NotifyServiceStart and NotifyServiceStop intents were described in the manifest file inside the <receiver> … <intent-filter> tag. Other requests will not start the receiver.
Appendix I. PM Usage (from Android console)
Code:
01.pm [list|path|install|uninstall]
02.pm list packages [-f]
03.pm list permission-groups
04.pm list permissions [-g] [-f] [-d] [-u] [GROUP]
05.pm path PACKAGE
06.pm install [-l] [-r] PATH
07.pm uninstall [-k] PACKAGE
08.
09.The list packages command prints all packages.
10.Use the -f option to see their associated file.
11.The list permission-groups command prints all known permission groups.
12.The list permissions command prints all known permissions, optionally
13.only those in GROUP.
14.
15.Use the -g option to organize by group.
16.Use the -f option to print all information.
17.Use the -s option for a short summary.
18.Use the -d option to only list dangerous permissions.
19.Use the -u option to list only the permissions users will see.
20.
21.The path command prints the path to the .apk of a package.
22.
23.The install command installs a package to the system. Use the -l option to
24. install the package with FORWARD_LOCK. Use the -r option to reinstall an
25.exisiting app, keeping its data.
26.The uninstall command removes a package from the system. Use the -k option
27.to keep the data and cache directories around after the package removal.
Appendix II. AM Usage (from Android console)
Code:
01.am [start|broadcast|instrument]
02.am start -D INTENT
03.am broadcast INTENT
04.am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>] [-w] <COMPONENT>
05.
06.INTENT is described with:
07. [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
08. [-c <CATEGORY> [-c <CATEGORY>] ...]
09. [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
10. [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
11. [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
12. [-n <COMPONENT>] [-f <FLAGS>] [<URI>]
13.
14.<h2>
Sources of the Sample Project can be downloaded at the article official page www(dot)apriorit(dot)com/our-company/dev-blog/130-development-for-android
All articles, code pieces, example project sources and other materials are the intellectual property of Apriorit Inc. and their authors.
All materials are distributed under the Creative Commons BY-NC License.

Categories

Resources