Re: [android-developers] Run http server in android

2013-07-01 Thread jrichards1...@googlemail.com
anyone?

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Run http server in android

2013-07-01 Thread jrichards1...@googlemail.com
ok i will try that

On Monday, July 1, 2013 1:28:15 PM UTC+1, Andrew Brampton wrote:

 I adapted Nanohttpd to work on Android: https://github.com/bramp/NanoHTTPd 
 you 
 can easily adapt that to make it a proxy.


 On 1 July 2013 04:15, jricha...@googlemail.com javascript: 
 jricha...@gmail.com javascript: wrote:

 anyone? 

 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to 
 android-d...@googlegroups.comjavascript:
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to android-developers+unsubscr...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Run http server in android

2013-07-01 Thread jrichards1...@googlemail.com
Edit. sorry that wont work. i get stuck on the proxy part. 

i get the folllowing error in the proxy code


*07-01 15:44:02.894: E/GAEProxy.ProxySettings(11267): error setting up 
webkit proxying = java.lang.RuntimeException: Can't create handler inside 
thread that has not called Looper.prepare()*

it happens when i call setProxy.

any suggestions?

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Run http server in android

2013-06-28 Thread jrichards1...@googlemail.com
Hi all.

is it possible to create a mini HTTP server that acts as a proxy where i 
can recieve any requests from a webview and it will pass that request to my 
http proxy server running inside the app that can then view the raw 
contents of that request(http headers, bodies etc) and handle it from my 
own proxy?

I can see that the apahce libraries only contain objects that allow you to 
create requests and handle responses but not how i can create a mini http 
server.

Thanks

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Run http server in android

2013-06-28 Thread jrichards1...@googlemail.com
i have setup my webview's proxy using this snippet of code below:

   * ProxySettings.setProxy(mContext, http://127.0.0.1;, PORT);*

Here is my socket server listener


*serverSocket = new ServerSocket(PORT);*
*thread = new Thread(runnable, this.getClass().getSimpleName());*
**
**
*public void startlistener() {*
*listening = true;*
*thread.start();*
**
*}*
**
*private Runnable runnable = new Runnable() {*
**
*@Override*
*public void run() {*
*while (listening) {*
*try {*
*Socket accept = serverSocket.accept();*
**
*String data = getData(accept);*
**
*httpHandler.handleRequest(data);*
**
*} catch (IOException e) {*
*// TODO Auto-generated catch block*
*e.printStackTrace();*
*}*
*}*
**
*}*
*};*

i have put a breakpoint on String data = getData(accept); and it never hits 
it

Below is the proxy class taken from https://gist.github.com/madeye/2297083 

   * public class ProxySettings {*
**
*private static final String TAG = GAEProxy.ProxySettings;*
**
*static final int PROXY_CHANGED = 193;*
**
*private static Object getDeclaredField(Object obj, String name)*
*throws SecurityException, NoSuchFieldException,*
*IllegalArgumentException, IllegalAccessException {*
*Field f = obj.getClass().getDeclaredField(name);*
*f.setAccessible(true);*
*Object out = f.get(obj);*
*// System.out.println(obj.getClass().getName() + . + name +  = +*
*// out);*
*return out;*
*}*
**
*public static Object getRequestQueue(Context ctx) throws Exception {*
*Object ret = null;*
*Class networkClass = Class.forName(android.webkit.Network);*
*if (networkClass != null) {*
*Object networkObj = invokeMethod(networkClass, getInstance,*
*new Object[] { ctx }, Context.class);*
*if (networkObj != null) {*
*ret = getDeclaredField(networkObj, mRequestQueue);*
*}*
*}*
*return ret;*
*}*
**
*private static Object invokeMethod(Object object, String methodName,*
*Object[] params, Class... types) throws Exception {*
*Object out = null;*
*Class c = object instanceof Class ? (Class) object : object.getClass();
*
*if (types != null) {*
*Method method = c.getMethod(methodName, types);*
*out = method.invoke(object, params);*
*} else {*
*Method method = c.getMethod(methodName);*
*out = method.invoke(object);*
*}*
*// System.out.println(object.getClass().getName() + . + methodName +*
*// () = + out);*
*return out;*
*}*
**
*public static void resetProxy(Context ctx) throws Exception {*
*Object requestQueueObject = getRequestQueue(ctx);*
*if (requestQueueObject != null) {*
*setDeclaredField(requestQueueObject, mProxyHost, null);*
*}*
*}*
**
*private static void setDeclaredField(Object obj, String name, Object 
value)*
*throws SecurityException, NoSuchFieldException,*
*IllegalArgumentException, IllegalAccessException {*
*Field f = obj.getClass().getDeclaredField(name);*
*f.setAccessible(true);*
*f.set(obj, value);*
*}*
**
*/***
* * Override WebKit Proxy settings*
* * *
* * @param ctx*
* *Android ApplicationContext*
* * @param host*
* * @param port*
* * @return true if Proxy was successfully set*
* */*
*public static boolean setProxy(Context ctx, String host, int port) {*
*boolean ret = false;*
*setSystemProperties(host, port);*
**
*try {*
*if (Build.VERSION.SDK_INT  14) {*
**
*Object requestQueueObject = getRequestQueue(ctx);*
*if (requestQueueObject != null) {*
*// Create Proxy config object and set it into request Q*
*HttpHost httpHost = new HttpHost(host, port, http);*
**
*setDeclaredField(requestQueueObject, mProxyHost, httpHost);*
*ret = true;*
*}*
**
*} else {*
*ret = setICSProxy(host, port);*
*}*
*} catch (Exception e) {*
*Log.e(TAG, error setting up webkit proxying, e);*
*}*
*return ret;*
*}*
**
*private static boolean setICSProxy(String host, int port)*
*throws ClassNotFoundException, NoSuchMethodException,*
*IllegalArgumentException, InstantiationException,*
*IllegalAccessException, InvocationTargetException {*
*Class webViewCoreClass = Class.forName(android.webkit.WebViewCore);*
*Class proxyPropertiesClass = Class*
*.forName(android.net.ProxyProperties);*
*if (webViewCoreClass != null  proxyPropertiesClass != null) {*
*Method m = webViewCoreClass.getDeclaredMethod(sendStaticMessage,*
*Integer.TYPE, Object.class);*
*Constructor c = proxyPropertiesClass.getConstructor(String.class,*
*Integer.TYPE, String.class);*
*m.setAccessible(true);*
*c.setAccessible(true);*
*Object properties = c.newInstance(host, port, null);*
*m.invoke(null, PROXY_CHANGED, properties);*
*return true;*
*}*
*

[android-developers] Get all requests and responses intercepted from a webview?

2013-06-24 Thread jrichards1...@googlemail.com


is there a way to get request and response objects from a webview?

for requests made from some webpage running in my webview, i want to 
intercept the full http request object(the headers, http method used, http 
body etc) and divert and send across that request into another channel.

For responses received from the webview, i want to do the same and get the 
object and its properties.

So far i have looked at the webviewClient android class which allows you to 
intercept url links executed by a webpage and intercept the resources it 
loads.

However, what i want to intercept, is any actual http requests the webpage 
makes. is this possible in Android webview?

thanks

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Get all requests and responses intercepted from a webview?

2013-06-24 Thread jrichards1...@googlemail.com
I am connected to  a seperate Web server implemented in java that basically 
handles all the requests we send through a webview.

At the moment i am using gmail to test if i can send the 
login/authentication request to our webserver and let our web server pass 
this request to google or whoever and get the response and sends it back to 
the client.

With current api's i cant see how i can intercept all http requests made 
inside a webview, only cat intercept URL hyperlink calls made by a user 
interacting with a website.

Not all interactions in a website are standard URL hyperlinks, some run JS 
etc so android's current webview API cant intercept this. It can in theory 
intercept the resources loaded but that only gives me a URL and a webview. 
It doesnt give me the headers that were used in the request, request body? 
request type etc. These are the variables i will need to pass to our web 
server who will use all these to login and authenticate us.

Thanks

On Monday, June 24, 2013 4:20:50 PM UTC+1, Lew wrote:

 You can solve this more easily using a proxy tool like Charles.

 This is the sort of thing usually not done from inside the app but to test 
 the app.
 Yes, there are apps whose main job is to handle HTTP, and they're the 
 exception, 
 but most apps want to rely on HTTP, not manage it. So as Kristopher 
 indicated, it's 
 a matter of what your use case is.

 For most situations where I've seen a need for the data you requested, 
 it's been 
 proper to use an external tool to get at the HTTP innards.

 -- 
 Lew

 On Monday, June 24, 2013 7:07:57 AM UTC-7, Kristopher Micinski wrote:

 Not as far as I know: there is no such mechanism through the API.  I 
 haven't checked what you can get access to if you use reflection, 
 though I also doubt you can do many tricks there either.  I don't know 
 much about WebKit internals, so I'm not sure if this is something that 
 would be possible. 

 However, maybe we could help if you better explain your use case.  Are 
 you trying to (e.g.,) make sure no bad AJAX code runs from a webpage 
 you loaded in your app? 

 Kris 

 On Mon, Jun 24, 2013 at 5:48 AM, jricha...@googlemail.com 
 jricha...@gmail.com wrote: 
  is there a way to get request and response objects from a webview? 
  
  for requests made from some webpage running in my webview, i want to 
  intercept the full http request object(the headers, http method used, 
 http 
  body etc) and divert and send across that request into another channel. 
  
  For responses received from the webview, i want to do the same and get 
 the 
  object and its properties. 
  
  So far i have looked at the webviewClient android class which allows 
 you to 
  intercept url links executed by a webpage and intercept the resources 
 it 
  loads. 
  
  However, what i want to intercept, is any actual http requests the 
 webpage 
  makes. is this possible in Android webview? 
  
  thanks 
  
  -- 
  -- 
  You received this message because you are subscribed to the Google 
  Groups Android Developers group. 
  To post to this group, send email to android-d...@googlegroups.com 
  To unsubscribe from this group, send email to 
  android-developers+unsubscr...@googlegroups.com 
  For more options, visit this group at 
  http://groups.google.com/group/android-developers?hl=en 
  --- 
  You received this message because you are subscribed to the Google 
 Groups 
  Android Developers group. 
  To unsubscribe from this group and stop receiving emails from it, send 
 an 
  email to android-developers+unsubscr...@googlegroups.com. 
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  



-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Get all requests and responses intercepted from a webview?

2013-06-24 Thread jrichards1...@googlemail.com
Hi

Basically when Web view display Gmail and u enter your username and password 
and click on the login button. Instead of the Website sending the request to 
Google. I want it to send to Our web server.  Our website server is basically 
the proxy. 

Why do we want this? The websites we will use can't make http requests without 
our proxy. 

I will try and post more detail when in am on my pc 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Get all requests and responses intercepted from a webview?

2013-06-24 Thread jrichards1...@googlemail.com
Hi

Basically when Web view display Gmail and u enter your username and password 
and click on the login button. Instead of the Website sending the request to 
Google. I want it to send to Our web server.  Our website server is basically 
the proxy. 

Why do we want this? The websites we will use can't make http requests without 
our proxy. 

I will try and post more detail when in am on my pc 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: listen for changes made in ContactMethod table

2010-04-19 Thread jrichards1...@googlemail.com
Any advice please? cheers in advance

On Apr 16, 12:54 pm, jrichards1...@googlemail.com
jrichards1...@googlemail.com wrote:
 Hi. i am trying tolistenout for forchangesmadeinContactMethodtableusing  the 
 code below:

 mPeopleObserver = new ContactContentObserver(mHandler);

 this.getContentResolver().registerContentObserver(Contacts.ContactMethods.C­ONTENT_URI,
                                 true, mPeopleObserver);

 It doesnt seem to work whenever i change a contacts email address or
 instant messanger details.

 i have a conentObserver method below that should catch and notify me
 of anychangesmadeto thetablebut it doesnt.

         /**
          * ContentObserver to get the call backs forchangesin the
 onChange
 method
          */
         private class ContactContentObserver extends ContentObserver
 {

                 public ContactContentObserver(Handler handler) {
                         super(handler);
                 }

                 public void onChange(boolean selfChange) {
                         // Excute Aggregation process
                         try {
                                 Log.d(AggregationService, onChange
 fired by content observer);
                                 AggregateContacts();
                         } catch (Exception e) {
                                 e.printStackTrace();
                         }
                 }
         }

 Cheers in advance.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] listen for changes made in ContactMethod table

2010-04-16 Thread jrichards1...@googlemail.com
Hi. i am trying to listen out for for changes made in ContactMethod
table using  the code below:

mPeopleObserver = new ContactContentObserver(mHandler);

this.getContentResolver().registerContentObserver(Contacts.ContactMethods.CONTENT_URI,
true, mPeopleObserver);

It doesnt seem to work whenever i change a contacts email address or
instant messanger details.

i have a conentObserver method below that should catch and notify me
of any changes made to the table but it doesnt.

/**
 * ContentObserver to get the call backs for changes in the
onChange
method
 */
private class ContactContentObserver extends ContentObserver
{

public ContactContentObserver(Handler handler) {
super(handler);
}

public void onChange(boolean selfChange) {
// Excute Aggregation process
try {
Log.d(AggregationService, onChange
fired by content observer);
AggregateContacts();
} catch (Exception e) {
e.printStackTrace();
}
}
}

Cheers in advance.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Initializing a custom view via XML

2010-04-07 Thread jrichards1...@googlemail.com
Yea i tried that already and diddnt work at all

On Apr 6, 10:37 am, Yahel kaye...@gmail.com wrote:
 Hi,

 Not sure at all but try to make sure you call the super.onXXX in each
 method you override.
 So that Android can works its magic before you do your own things
 Like in your onMeasure

 Yahel

 On 6 avr, 10:41, jrichards1...@googlemail.com



 jrichards1...@googlemail.com wrote:
  Bump, any suggestions? thanks

  On Apr 5, 7:32 pm, jrichards1...@googlemail.com

  jrichards1...@googlemail.com wrote:
   As the title says, i am trying to use a custom view i have created and
   initializing the size of it using the above xml code snippet located
   inside my layout folder.:

   com.Resources.Gui.ScrollingText  android:id=@+id/rss
                   android:layout_height=wrap_content
   android:layout_alignParentBottom=true
                   android:layout_width=wrap_content /

   The height and width of my custom view doesnt seem to work. i have to
   manualy hard code it to adjust and see my custom view using the bit of
   code below located on my main activity class:

   rssText = (ScrollingText) findViewById(R.id.rss);
   rssText.setWidthHeight(200,50);

   Code below is the ScrollingText methods.

   Constructor:
           public ScrollingText(Context context, AttributeSet attrs) {
                   super(context, attrs);

                   textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                   textPaint.setColor(Color.BLACK);
                   textBoxPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                   textBoxPaint.setColor(Color.WHITE);
                   textPaint.setTextSize(20);

           }

   public void setWidthHeight(int width, int height){
                   this.height = height;
                   this.width = width;
           }

           private void drawTextBox(Canvas c) {

                   // TODO: Experiment with these co-ordinates
                   c.drawRect(10, 0, width - 10, height, textBoxPaint);

           }

           private void drawTextRss(Canvas c) {
                   int textHeight = (int) textPaint.getTextSize();
                   printDebug(text height =  + textHeight);
                   c.drawText(text, 10, height + 10, textPaint);
                   //c.drawText(Hello, why doesnt this work, 
   10, 50,
   textPaint);
           }

           @Override
           protected void onDraw(Canvas canvas) {
                   // TODO Auto-generated method stub
                   super.onDraw(canvas);
                   drawTextBox(canvas);
                   drawTextRss(canvas);
                   setVisibility(VISIBLE);
           }

           @Override
           protected void onMeasure(int widthMeasureSpec, int 
   heightMeasureSpec)
   {

                   setMeasuredDimension(width,height);
                   }

   I hope my explanations and code is enough to help me figure out how i
   can set the size of the custom view from the xml layout file.

   Not sure why android:layout_height=wrap_content
                   android:layout_width=wrap_content doesnt ??

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.


[android-developers] Re: Initializing a custom view via XML

2010-04-06 Thread jrichards1...@googlemail.com
Bump, any suggestions? thanks

On Apr 5, 7:32 pm, jrichards1...@googlemail.com
jrichards1...@googlemail.com wrote:
 As the title says, i am trying to use a custom view i have created and
 initializing the size of it using the above xml code snippet located
 inside my layout folder.:

 com.Resources.Gui.ScrollingText  android:id=@+id/rss
                 android:layout_height=wrap_content
 android:layout_alignParentBottom=true
                 android:layout_width=wrap_content /

 The height and width of my custom view doesnt seem to work. i have to
 manualy hard code it to adjust and see my custom view using the bit of
 code below located on my main activity class:

 rssText = (ScrollingText) findViewById(R.id.rss);
 rssText.setWidthHeight(200,50);

 Code below is the ScrollingText methods.

 Constructor:
         public ScrollingText(Context context, AttributeSet attrs) {
                 super(context, attrs);

                 textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                 textPaint.setColor(Color.BLACK);
                 textBoxPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                 textBoxPaint.setColor(Color.WHITE);
                 textPaint.setTextSize(20);

         }

 public void setWidthHeight(int width, int height){
                 this.height = height;
                 this.width = width;
         }

         private void drawTextBox(Canvas c) {

                 // TODO: Experiment with these co-ordinates
                 c.drawRect(10, 0, width - 10, height, textBoxPaint);

         }

         private void drawTextRss(Canvas c) {
                 int textHeight = (int) textPaint.getTextSize();
                 printDebug(text height =  + textHeight);
                 c.drawText(text, 10, height + 10, textPaint);
                 //c.drawText(Hello, why doesnt this work, 10, 
 50,
 textPaint);
         }

         @Override
         protected void onDraw(Canvas canvas) {
                 // TODO Auto-generated method stub
                 super.onDraw(canvas);
                 drawTextBox(canvas);
                 drawTextRss(canvas);
                 setVisibility(VISIBLE);
         }

         @Override
         protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
 {

                 setMeasuredDimension(width,height);
                 }

 I hope my explanations and code is enough to help me figure out how i
 can set the size of the custom view from the xml layout file.

 Not sure why android:layout_height=wrap_content
                 android:layout_width=wrap_content doesnt ??

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.


[android-developers] Initializing a custom view via XML

2010-04-05 Thread jrichards1...@googlemail.com
As the title says, i am trying to use a custom view i have created and
initializing the size of it using the above xml code snippet located
inside my layout folder.:

com.Resources.Gui.ScrollingText  android:id=@+id/rss
android:layout_height=wrap_content
android:layout_alignParentBottom=true
android:layout_width=wrap_content /

The height and width of my custom view doesnt seem to work. i have to
manualy hard code it to adjust and see my custom view using the bit of
code below located on my main activity class:

rssText = (ScrollingText) findViewById(R.id.rss);
rssText.setWidthHeight(200,50);

Code below is the ScrollingText methods.

Constructor:
public ScrollingText(Context context, AttributeSet attrs) {
super(context, attrs);

textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(Color.BLACK);
textBoxPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
textBoxPaint.setColor(Color.WHITE);
textPaint.setTextSize(20);




}


public void setWidthHeight(int width, int height){
this.height = height;
this.width = width;
}


private void drawTextBox(Canvas c) {

// TODO: Experiment with these co-ordinates
c.drawRect(10, 0, width - 10, height, textBoxPaint);

}

private void drawTextRss(Canvas c) {
int textHeight = (int) textPaint.getTextSize();
printDebug(text height =  + textHeight);
c.drawText(text, 10, height + 10, textPaint);
//c.drawText(Hello, why doesnt this work, 10, 50,
textPaint);
}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
drawTextBox(canvas);
drawTextRss(canvas);
setVisibility(VISIBLE);
}



@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{


setMeasuredDimension(width,height);
}

I hope my explanations and code is enough to help me figure out how i
can set the size of the custom view from the xml layout file.

Not sure why android:layout_height=wrap_content
android:layout_width=wrap_content doesnt ??

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.


[android-developers] J-unit testing issues

2009-09-08 Thread jrichards1...@googlemail.com

Hi, i am having two issues when doing Junit testing on my code. the
first issue is i cant seem to unit test a private method or class and
was wondering if its possible to do so.

the second issue is that i have setup a seperate android project for
doing all the testing and have just added the main project into its
build path so i can call methods from the main android project i am
testing on. Whenever i call something from the main project ie Myclass
myclass = new Myclass(); it fails saying that the Test Run failed with
a java.lang.Verify error

i am simply creating a new class object from my main project into my
AndroidTestCase class so im not quite sure what the issue is.

i am basicly having the exact same issue as someone in this link
http://dtmilano.blogspot.com/2009/07/android-testing-on-android-platform_4442.html
who has posted a comment about it

Here below is the original comment made by someone with the same issue
i have.

[quote]

hey diego, i'm trying to create a unit test by following your
tutorial. I've arrived in which i created a test method for one of my
class (called MyClass for example) which resides in my main package
(say, com.package.main). And yes, I've put my main project in the test
build path configuration.

And then, I tried to create the class in one of my test case in a
usual manner of:

MyClass myClass = new MyClass()

And then I tried to run the test project and it always gives Test run
failed messages. This happens eveytime I wanted to instantiate any
class that resides in my main project. Can you help me on this? Thanks
in advance :).

[/quote]

Anyways, thanks for your time in reading this and im hoping someone
here can help me as i really want to create a seperate project with
all my Testcase's and TestSuits instead of including them in the main
project. I also do not want to make my private class and methods
public just for Unit testing.

Thanks again and looking forward to some of your advice.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---