Re: [android-developers] Re: RPC service with notification

2011-01-10 Thread Kostya Vasilyev

Jackie,

I already gave you one suggestion, it had to do with 
AndroidServiceImpl.class.


Here is another:

If inner classes are a new thing to you, don't use one, they can be 
confusing at first.


Make a method in your Service class proper, call it from inside 
AndroidServiceImpl, and then you're back inside your service class, and 
on sample code territory.


Also, using a non-static inner class for the binder (like you are doing) 
causes a memory leak. Here is someone's very nice blog post explaining 
why this happens and what to do about it:


http://www.ozdroid.com/#!BLOG/2010/12/19/How_to_make_a_local_Service_and_bind_to_it_in_Android

-- Kostya

10.01.2011 5:24, Jackie G. пишет:

Thanks so much for taking so much time to try and help me out. Here is
how I create the Notification

private Notification notification;
private static final int NOTIFICATION_ID=1;
protected Context context;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return new AndroidServiceImpl();
}
@Override
public void onCreate(){
super.onCreate();
NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

I think the real problem is with the context in the Impl. Can I even
get an application context from the impl? Should this be passed to the
service from the application? Can it be grabed from AndroidService?

public class AndroidServiceImpl extends IAndroidService.Stub{
public String getAndroidText(String conversation)
throws RemoteException {
// TODO Auto-generated method stub
NotificationManager currentManager = 
(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

Context context = getApplicationContext();

This is for an open source class I am teaching so I can create a
Google project tomorrow if you still want to help. That way you can
see the whole code.

On Jan 9, 2:39 pm, Kostya Vasilyevkmans...@gmail.com  wrote:

How are you creating notification ?

09.01.2011 22:33, Jackie G. пишет:




Also double checked and it is hitting the breakpoint.
On Jan 9, 11:35 am, Kostya Vasilyevkmans...@gmail.comwrote:

I don't see code in getAndroidText that would initialize notification.
It should be something like:
notification = new Notification(R.drawable.status_icon, Hello,
System.currentTimeMillis());
And does getAndroidText really get called? You can verify by setting a
breakpoint.
-- Kostya
09.01.2011 19:03, Jackie G. пишет:

Kostya,
Thanks for the advice I did as you have said and everything compiles.
There is still a problem, however, the notification manager does not
show the updates I am expecting.
Here is my Service Impl
public class AndroidServiceImpl extends IAndroidService.Stub{
   public String getAndroidText(String conversation)
   throws RemoteException {
   // TODO Auto-generated method stub
   NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
   Context context = getApplicationContext();
   CharSequence contentTitle = Sogeti;
   CharSequence contentText = This is a message;
   Intent notificationIntent = new
Intent(AndroidService.this, AndroidServiceImpl.class);
   PendingIntent contentIntent =
PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
0);
   notification.setLatestEventInfo(context, contentTitle,
contentText, contentIntent);
   currentManager.notify(NOTIFICATION_ID, notification);
   return Android Services are Fun!;
   }
   }
And the parts of the activity that call the service...
@Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   bindService(new
Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
Context.BIND_AUTO_CREATE);
   serviceBtn = (Button)findViewById(R.id.serviceBtn);
   serviceBtn.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
   callService();
   }
   });
   }
   private void callService(){
   try{
   String text = androidService.getAndroidText(Test);
   String other = test;
   }
   catch(NullPointerException npe){
   //TODO: Log Null pointer
   }
   catch(RemoteException rme){
   //TODO: log errors
   }
   }
On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com  wrote:

Intent(Context context, Class cls)
needs a Context as first parameter, which
AndroidService.AndroidServiceImpl is not :)
I see you 

[android-developers] Re: RPC service with notification

2011-01-09 Thread Jackie G.
Kostya,

Thanks for the advice I did as you have said and everything compiles.
There is still a problem, however, the notification manager does not
show the updates I am expecting.

Here is my Service Impl
public class AndroidServiceImpl extends IAndroidService.Stub{
public String getAndroidText(String conversation)
throws RemoteException {
// TODO Auto-generated method stub
NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

Context context = getApplicationContext();
CharSequence contentTitle = Sogeti;
CharSequence contentText = This is a message;
Intent notificationIntent = new
Intent(AndroidService.this, AndroidServiceImpl.class);
PendingIntent contentIntent =
PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
0);
notification.setLatestEventInfo(context, contentTitle,
contentText, contentIntent);

currentManager.notify(NOTIFICATION_ID, notification);
return Android Services are Fun!;
}
}

And the parts of the activity that call the service...


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bindService(new
Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
Context.BIND_AUTO_CREATE);
serviceBtn = (Button)findViewById(R.id.serviceBtn);
serviceBtn.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
callService();
}
});
}
private void callService(){
try{
String text = androidService.getAndroidText(Test);
String other = test;
}
catch(NullPointerException npe){
//TODO: Log Null pointer
}
catch(RemoteException rme){
//TODO: log errors
}
}


On Jan 8, 3:05 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 Intent(Context context, Class cls)

 needs a Context as first parameter, which
 AndroidService.AndroidServiceImpl is not :)

 I see you have a variable called context, you can probably use that,
 or use standard Java notation AndroidService.this to refer to the
 enclosing class instance, which as far as I can see, is a Service, which
 is a Context.

 -- Kostya

 08.01.2011 22:55, Jackie G. пишет:



  Hi everyone,

  I am looking for someone to help me with a simple RPC service. What I
  want to do is create a notification message once the service is
  started and every time the RPC interface is called I want to update
  the notification. Creating the notification works but when I add the
  following...

  P.S. new to GGs so sorry if there is some secretcode  tag

  public String getAndroidText(String conversation)  throws
  RemoteException {
                     NotificationManager currentManager = 
  (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
                     Context context = getApplicationContext();
                     CharSequence contentTitle = Sogeti;
                     CharSequence contentText = This is a message;
                     Intent notificationIntent = new Intent(this,
  AndroidServiceImpl.class);
                     PendingIntent contentIntent = 
  PendingIntent.getActivity(this, 0,
  notificationIntent, 0);
                     notification.setLatestEventInfo(context, contentTitle, 
  contentText,
  contentIntent);
                     currentManager.notify(NOTIFICATION_ID, notification);
                     return Android Services are Fun!;
             }

  to my inner impl class, however, I get the following compile error...

  The constructor Intent(AndroidService.AndroidServiceImpl,
    ClassAndroidService.AndroidServiceImpl) is undefined

  Can someone help me do this the right way?

  Thanks!

 --
 Kostya Vasilyev -- WiFi Manager + pretty widget 
 --http://kmansoft.wordpress.com

-- 
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


Re: [android-developers] Re: RPC service with notification

2011-01-09 Thread Kostya Vasilyev

I don't see code in getAndroidText that would initialize notification.

It should be something like:

notification = new Notification(R.drawable.status_icon, Hello, 
System.currentTimeMillis());


And does getAndroidText really get called? You can verify by setting a 
breakpoint.


-- Kostya

09.01.2011 19:03, Jackie G. пишет:

Kostya,

Thanks for the advice I did as you have said and everything compiles.
There is still a problem, however, the notification manager does not
show the updates I am expecting.

Here is my Service Impl
public class AndroidServiceImpl extends IAndroidService.Stub{
 public String getAndroidText(String conversation)
 throws RemoteException {
 // TODO Auto-generated method stub
 NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

 Context context = getApplicationContext();
 CharSequence contentTitle = Sogeti;
 CharSequence contentText = This is a message;
 Intent notificationIntent = new
Intent(AndroidService.this, AndroidServiceImpl.class);
 PendingIntent contentIntent =
PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
0);
 notification.setLatestEventInfo(context, contentTitle,
contentText, contentIntent);

 currentManager.notify(NOTIFICATION_ID, notification);
 return Android Services are Fun!;
 }
 }

And the parts of the activity that call the service...


@Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 bindService(new
Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
Context.BIND_AUTO_CREATE);
 serviceBtn = (Button)findViewById(R.id.serviceBtn);
 serviceBtn.setOnClickListener(new OnClickListener() {

 public void onClick(View v) {
 callService();
 }
 });
 }
 private void callService(){
 try{
 String text = androidService.getAndroidText(Test);
 String other = test;
 }
 catch(NullPointerException npe){
 //TODO: Log Null pointer
 }
 catch(RemoteException rme){
 //TODO: log errors
 }
 }


On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com  wrote:

Intent(Context context, Class cls)

needs a Context as first parameter, which
AndroidService.AndroidServiceImpl is not :)

I see you have a variable called context, you can probably use that,
or use standard Java notation AndroidService.this to refer to the
enclosing class instance, which as far as I can see, is a Service, which
is a Context.

-- Kostya

08.01.2011 22:55, Jackie G. пишет:




Hi everyone,
I am looking for someone to help me with a simple RPC service. What I
want to do is create a notification message once the service is
started and every time the RPC interface is called I want to update
the notification. Creating the notification works but when I add the
following...
P.S. new to GGs so sorry if there is some secretcodetag
public String getAndroidText(String conversation)  throws
RemoteException {
NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
Context context = getApplicationContext();
CharSequence contentTitle = Sogeti;
CharSequence contentText = This is a message;
Intent notificationIntent = new Intent(this,
AndroidServiceImpl.class);
PendingIntent contentIntent = 
PendingIntent.getActivity(this, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, 
contentText,
contentIntent);
currentManager.notify(NOTIFICATION_ID, notification);
return Android Services are Fun!;
}
to my inner impl class, however, I get the following compile error...
The constructor Intent(AndroidService.AndroidServiceImpl,
   ClassAndroidService.AndroidServiceImpl) is undefined
Can someone help me do this the right way?
Thanks!

--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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: RPC service with notification

2011-01-09 Thread Jackie G.
I set this in my Service onCreate method and then share it through a
global variable. Should I create a new notification within the
Impl.Stub class? Do I need to remove the old notification?

Thanks again for all your help.

On Jan 9, 11:35 am, Kostya Vasilyev kmans...@gmail.com wrote:
 I don't see code in getAndroidText that would initialize notification.

 It should be something like:

 notification = new Notification(R.drawable.status_icon, Hello,
 System.currentTimeMillis());

 And does getAndroidText really get called? You can verify by setting a
 breakpoint.

 -- Kostya

 09.01.2011 19:03, Jackie G. пишет:



  Kostya,

  Thanks for the advice I did as you have said and everything compiles.
  There is still a problem, however, the notification manager does not
  show the updates I am expecting.

  Here is my Service Impl
  public class AndroidServiceImpl extends IAndroidService.Stub{
           public String getAndroidText(String conversation)
                   throws RemoteException {
               // TODO Auto-generated method stub
               NotificationManager currentManager = (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);

               Context context = getApplicationContext();
               CharSequence contentTitle = Sogeti;
               CharSequence contentText = This is a message;
               Intent notificationIntent = new
  Intent(AndroidService.this, AndroidServiceImpl.class);
               PendingIntent contentIntent =
  PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
  0);
               notification.setLatestEventInfo(context, contentTitle,
  contentText, contentIntent);

               currentManager.notify(NOTIFICATION_ID, notification);
               return Android Services are Fun!;
           }
       }

  And the parts of the activity that call the service...

  @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
           bindService(new
  Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
  Context.BIND_AUTO_CREATE);
           serviceBtn = (Button)findViewById(R.id.serviceBtn);
           serviceBtn.setOnClickListener(new OnClickListener() {

               public void onClick(View v) {
                   callService();
               }
           });
       }
       private void callService(){
           try{
               String text = androidService.getAndroidText(Test);
               String other = test;
           }
           catch(NullPointerException npe){
               //TODO: Log Null pointer
           }
           catch(RemoteException rme){
               //TODO: log errors
           }
       }

  On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com  wrote:
  Intent(Context context, Class cls)

  needs a Context as first parameter, which
  AndroidService.AndroidServiceImpl is not :)

  I see you have a variable called context, you can probably use that,
  or use standard Java notation AndroidService.this to refer to the
  enclosing class instance, which as far as I can see, is a Service, which
  is a Context.

  -- Kostya

  08.01.2011 22:55, Jackie G. пишет:

  Hi everyone,
  I am looking for someone to help me with a simple RPC service. What I
  want to do is create a notification message once the service is
  started and every time the RPC interface is called I want to update
  the notification. Creating the notification works but when I add the
  following...
  P.S. new to GGs so sorry if there is some secretcode    tag
  public String getAndroidText(String conversation)  throws
  RemoteException {
                      NotificationManager currentManager = 
  (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
                      Context context = getApplicationContext();
                      CharSequence contentTitle = Sogeti;
                      CharSequence contentText = This is a message;
                      Intent notificationIntent = new Intent(this,
  AndroidServiceImpl.class);
                      PendingIntent contentIntent = 
  PendingIntent.getActivity(this, 0,
  notificationIntent, 0);
                      notification.setLatestEventInfo(context, 
  contentTitle, contentText,
  contentIntent);
                      currentManager.notify(NOTIFICATION_ID, notification);
                      return Android Services are Fun!;
              }
  to my inner impl class, however, I get the following compile error...
  The constructor Intent(AndroidService.AndroidServiceImpl,
     ClassAndroidService.AndroidServiceImpl) is undefined
  Can someone help me do this the right way?
  Thanks!
  --
  Kostya Vasilyev -- WiFi Manager + pretty widget 
  --http://kmansoft.wordpress.com

 --
 Kostya Vasilyev -- WiFi Manager + pretty widget 
 --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups 

[android-developers] Re: RPC service with notification

2011-01-09 Thread Jackie G.
Also double checked and it is hitting the breakpoint.

On Jan 9, 11:35 am, Kostya Vasilyev kmans...@gmail.com wrote:
 I don't see code in getAndroidText that would initialize notification.

 It should be something like:

 notification = new Notification(R.drawable.status_icon, Hello,
 System.currentTimeMillis());

 And does getAndroidText really get called? You can verify by setting a
 breakpoint.

 -- Kostya

 09.01.2011 19:03, Jackie G. пишет:



  Kostya,

  Thanks for the advice I did as you have said and everything compiles.
  There is still a problem, however, the notification manager does not
  show the updates I am expecting.

  Here is my Service Impl
  public class AndroidServiceImpl extends IAndroidService.Stub{
           public String getAndroidText(String conversation)
                   throws RemoteException {
               // TODO Auto-generated method stub
               NotificationManager currentManager = (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);

               Context context = getApplicationContext();
               CharSequence contentTitle = Sogeti;
               CharSequence contentText = This is a message;
               Intent notificationIntent = new
  Intent(AndroidService.this, AndroidServiceImpl.class);
               PendingIntent contentIntent =
  PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
  0);
               notification.setLatestEventInfo(context, contentTitle,
  contentText, contentIntent);

               currentManager.notify(NOTIFICATION_ID, notification);
               return Android Services are Fun!;
           }
       }

  And the parts of the activity that call the service...

  @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
           bindService(new
  Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
  Context.BIND_AUTO_CREATE);
           serviceBtn = (Button)findViewById(R.id.serviceBtn);
           serviceBtn.setOnClickListener(new OnClickListener() {

               public void onClick(View v) {
                   callService();
               }
           });
       }
       private void callService(){
           try{
               String text = androidService.getAndroidText(Test);
               String other = test;
           }
           catch(NullPointerException npe){
               //TODO: Log Null pointer
           }
           catch(RemoteException rme){
               //TODO: log errors
           }
       }

  On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com  wrote:
  Intent(Context context, Class cls)

  needs a Context as first parameter, which
  AndroidService.AndroidServiceImpl is not :)

  I see you have a variable called context, you can probably use that,
  or use standard Java notation AndroidService.this to refer to the
  enclosing class instance, which as far as I can see, is a Service, which
  is a Context.

  -- Kostya

  08.01.2011 22:55, Jackie G. пишет:

  Hi everyone,
  I am looking for someone to help me with a simple RPC service. What I
  want to do is create a notification message once the service is
  started and every time the RPC interface is called I want to update
  the notification. Creating the notification works but when I add the
  following...
  P.S. new to GGs so sorry if there is some secretcode    tag
  public String getAndroidText(String conversation)  throws
  RemoteException {
                      NotificationManager currentManager = 
  (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
                      Context context = getApplicationContext();
                      CharSequence contentTitle = Sogeti;
                      CharSequence contentText = This is a message;
                      Intent notificationIntent = new Intent(this,
  AndroidServiceImpl.class);
                      PendingIntent contentIntent = 
  PendingIntent.getActivity(this, 0,
  notificationIntent, 0);
                      notification.setLatestEventInfo(context, 
  contentTitle, contentText,
  contentIntent);
                      currentManager.notify(NOTIFICATION_ID, notification);
                      return Android Services are Fun!;
              }
  to my inner impl class, however, I get the following compile error...
  The constructor Intent(AndroidService.AndroidServiceImpl,
     ClassAndroidService.AndroidServiceImpl) is undefined
  Can someone help me do this the right way?
  Thanks!
  --
  Kostya Vasilyev -- WiFi Manager + pretty widget 
  --http://kmansoft.wordpress.com

 --
 Kostya Vasilyev -- WiFi Manager + pretty widget 
 --http://kmansoft.wordpress.com

-- 
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

Re: [android-developers] Re: RPC service with notification

2011-01-09 Thread Kostya Vasilyev

How are you creating notification ?

09.01.2011 22:33, Jackie G. пишет:

Also double checked and it is hitting the breakpoint.

On Jan 9, 11:35 am, Kostya Vasilyevkmans...@gmail.com  wrote:

I don't see code in getAndroidText that would initialize notification.

It should be something like:

notification = new Notification(R.drawable.status_icon, Hello,
System.currentTimeMillis());

And does getAndroidText really get called? You can verify by setting a
breakpoint.

-- Kostya

09.01.2011 19:03, Jackie G. пишет:




Kostya,
Thanks for the advice I did as you have said and everything compiles.
There is still a problem, however, the notification manager does not
show the updates I am expecting.
Here is my Service Impl
public class AndroidServiceImpl extends IAndroidService.Stub{
  public String getAndroidText(String conversation)
  throws RemoteException {
  // TODO Auto-generated method stub
  NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
  Context context = getApplicationContext();
  CharSequence contentTitle = Sogeti;
  CharSequence contentText = This is a message;
  Intent notificationIntent = new
Intent(AndroidService.this, AndroidServiceImpl.class);
  PendingIntent contentIntent =
PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
0);
  notification.setLatestEventInfo(context, contentTitle,
contentText, contentIntent);
  currentManager.notify(NOTIFICATION_ID, notification);
  return Android Services are Fun!;
  }
  }
And the parts of the activity that call the service...
@Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  bindService(new
Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
Context.BIND_AUTO_CREATE);
  serviceBtn = (Button)findViewById(R.id.serviceBtn);
  serviceBtn.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
  callService();
  }
  });
  }
  private void callService(){
  try{
  String text = androidService.getAndroidText(Test);
  String other = test;
  }
  catch(NullPointerException npe){
  //TODO: Log Null pointer
  }
  catch(RemoteException rme){
  //TODO: log errors
  }
  }
On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.comwrote:

Intent(Context context, Class cls)
needs a Context as first parameter, which
AndroidService.AndroidServiceImpl is not :)
I see you have a variable called context, you can probably use that,
or use standard Java notation AndroidService.this to refer to the
enclosing class instance, which as far as I can see, is a Service, which
is a Context.
-- Kostya
08.01.2011 22:55, Jackie G. пишет:

Hi everyone,
I am looking for someone to help me with a simple RPC service. What I
want to do is create a notification message once the service is
started and every time the RPC interface is called I want to update
the notification. Creating the notification works but when I add the
following...
P.S. new to GGs so sorry if there is some secretcode  tag
public String getAndroidText(String conversation)  throws
RemoteException {
 NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
 Context context = getApplicationContext();
 CharSequence contentTitle = Sogeti;
 CharSequence contentText = This is a message;
 Intent notificationIntent = new Intent(this,
AndroidServiceImpl.class);
 PendingIntent contentIntent = 
PendingIntent.getActivity(this, 0,
notificationIntent, 0);
 notification.setLatestEventInfo(context, contentTitle, 
contentText,
contentIntent);
 currentManager.notify(NOTIFICATION_ID, notification);
 return Android Services are Fun!;
 }
to my inner impl class, however, I get the following compile error...
The constructor Intent(AndroidService.AndroidServiceImpl,
ClassAndroidService.AndroidServiceImpl) is undefined
Can someone help me do this the right way?
Thanks!

--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com

--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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] Re: RPC service with notification

2011-01-09 Thread Jackie G.
private Notification notification;
private static final int NOTIFICATION_ID=1;

public void onCreate(){
super.onCreate();
NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notification = new Notification(R.drawable.stat_notify_chat, Yo
Mama, System.currentTimeMillis());

...
}

On Jan 9, 2:39 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 How are you creating notification ?

 09.01.2011 22:33, Jackie G. пишет:



  Also double checked and it is hitting the breakpoint.

  On Jan 9, 11:35 am, Kostya Vasilyevkmans...@gmail.com  wrote:
  I don't see code in getAndroidText that would initialize notification.

  It should be something like:

  notification = new Notification(R.drawable.status_icon, Hello,
  System.currentTimeMillis());

  And does getAndroidText really get called? You can verify by setting a
  breakpoint.

  -- Kostya

  09.01.2011 19:03, Jackie G. пишет:

  Kostya,
  Thanks for the advice I did as you have said and everything compiles.
  There is still a problem, however, the notification manager does not
  show the updates I am expecting.
  Here is my Service Impl
  public class AndroidServiceImpl extends IAndroidService.Stub{
            public String getAndroidText(String conversation)
                    throws RemoteException {
                // TODO Auto-generated method stub
                NotificationManager currentManager = (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
                Context context = getApplicationContext();
                CharSequence contentTitle = Sogeti;
                CharSequence contentText = This is a message;
                Intent notificationIntent = new
  Intent(AndroidService.this, AndroidServiceImpl.class);
                PendingIntent contentIntent =
  PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
  0);
                notification.setLatestEventInfo(context, contentTitle,
  contentText, contentIntent);
                currentManager.notify(NOTIFICATION_ID, notification);
                return Android Services are Fun!;
            }
        }
  And the parts of the activity that call the service...
  @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            bindService(new
  Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
  Context.BIND_AUTO_CREATE);
            serviceBtn = (Button)findViewById(R.id.serviceBtn);
            serviceBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    callService();
                }
            });
        }
        private void callService(){
            try{
                String text = androidService.getAndroidText(Test);
                String other = test;
            }
            catch(NullPointerException npe){
                //TODO: Log Null pointer
            }
            catch(RemoteException rme){
                //TODO: log errors
            }
        }
  On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com    wrote:
  Intent(Context context, Class cls)
  needs a Context as first parameter, which
  AndroidService.AndroidServiceImpl is not :)
  I see you have a variable called context, you can probably use that,
  or use standard Java notation AndroidService.this to refer to the
  enclosing class instance, which as far as I can see, is a Service, which
  is a Context.
  -- Kostya
  08.01.2011 22:55, Jackie G. пишет:
  Hi everyone,
  I am looking for someone to help me with a simple RPC service. What I
  want to do is create a notification message once the service is
  started and every time the RPC interface is called I want to update
  the notification. Creating the notification works but when I add the
  following...
  P.S. new to GGs so sorry if there is some secretcode      tag
  public String getAndroidText(String conversation)  throws
  RemoteException {
                       NotificationManager currentManager = 
  (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
                       Context context = getApplicationContext();
                       CharSequence contentTitle = Sogeti;
                       CharSequence contentText = This is a message;
                       Intent notificationIntent = new Intent(this,
  AndroidServiceImpl.class);
                       PendingIntent contentIntent = 
  PendingIntent.getActivity(this, 0,
  notificationIntent, 0);
                       notification.setLatestEventInfo(context, 
  contentTitle, contentText,
  contentIntent);
                       currentManager.notify(NOTIFICATION_ID, 
  notification);
                       return Android Services are Fun!;
               }
  to my inner impl class, however, I get the following compile error...
  The constructor 

Re: [android-developers] Re: RPC service with notification

2011-01-09 Thread Kostya Vasilyev

onCreate looks good.

A couple things jumped at me just now in your original code:

Intent notificationIntent = new 
Intent(AndroidService.this,*AndroidServiceImpl.class*);


The second parameter is not a class known to Android, so the Intent is 
not valid. Just because you can use a Java .class reference here, 
doesn't mean it's meaningful to Android.


PendingIntent contentIntent = 
PendingIntent.getActivity(AndroidService.this, 0, notificationIntent, 0);


Here you're implying that notificationIntent refers to an Activity, 
whereas it doesn't refer to anything Android, even a service.


I don't know how much checking Android does on this and when, but these 
intents are not valid.


Make an Activity in your project (you probably already do from Eclipse's 
Android project wizard) and try changing the code like this:


Intent notificationIntent = new 
Intent(AndroidService.this,*TestActivity.class*);
PendingIntent contentIntent = PendingIntent.getActivity(AndroidService.this, 0, 
notificationIntent, 0);

... rest is the same ...

-- Kostya

09.01.2011 23:47, Jackie G. пишет:

private Notification notification;
private static final int NOTIFICATION_ID=1;

public void onCreate(){
super.onCreate();
NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notification = new Notification(R.drawable.stat_notify_chat, Yo
Mama, System.currentTimeMillis());

...
}

On Jan 9, 2:39 pm, Kostya Vasilyevkmans...@gmail.com  wrote:

How are you creating notification ?

09.01.2011 22:33, Jackie G. пишет:




Also double checked and it is hitting the breakpoint.
On Jan 9, 11:35 am, Kostya Vasilyevkmans...@gmail.comwrote:

I don't see code in getAndroidText that would initialize notification.
It should be something like:
notification = new Notification(R.drawable.status_icon, Hello,
System.currentTimeMillis());
And does getAndroidText really get called? You can verify by setting a
breakpoint.
-- Kostya
09.01.2011 19:03, Jackie G. пишет:

Kostya,
Thanks for the advice I did as you have said and everything compiles.
There is still a problem, however, the notification manager does not
show the updates I am expecting.
Here is my Service Impl
public class AndroidServiceImpl extends IAndroidService.Stub{
   public String getAndroidText(String conversation)
   throws RemoteException {
   // TODO Auto-generated method stub
   NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
   Context context = getApplicationContext();
   CharSequence contentTitle = Sogeti;
   CharSequence contentText = This is a message;
   Intent notificationIntent = new
Intent(AndroidService.this, AndroidServiceImpl.class);
   PendingIntent contentIntent =
PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
0);
   notification.setLatestEventInfo(context, contentTitle,
contentText, contentIntent);
   currentManager.notify(NOTIFICATION_ID, notification);
   return Android Services are Fun!;
   }
   }
And the parts of the activity that call the service...
@Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   bindService(new
Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
Context.BIND_AUTO_CREATE);
   serviceBtn = (Button)findViewById(R.id.serviceBtn);
   serviceBtn.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
   callService();
   }
   });
   }
   private void callService(){
   try{
   String text = androidService.getAndroidText(Test);
   String other = test;
   }
   catch(NullPointerException npe){
   //TODO: Log Null pointer
   }
   catch(RemoteException rme){
   //TODO: log errors
   }
   }
On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com  wrote:

Intent(Context context, Class cls)
needs a Context as first parameter, which
AndroidService.AndroidServiceImpl is not :)
I see you have a variable called context, you can probably use that,
or use standard Java notation AndroidService.this to refer to the
enclosing class instance, which as far as I can see, is a Service, which
is a Context.
-- Kostya
08.01.2011 22:55, Jackie G. пишет:

Hi everyone,
I am looking for someone to help me with a simple RPC service. What I
want to do is create a notification message once the service is
started and every time the RPC interface is called I want to update
the notification. Creating the notification works but when I add the
following...
P.S. new to GGs so sorry if there is some secretcodetag
public 

[android-developers] Re: RPC service with notification

2011-01-09 Thread Jackie G.
Thanks so much for taking so much time to try and help me out. Here is
how I create the Notification

private Notification notification;
private static final int NOTIFICATION_ID=1;
protected Context context;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return new AndroidServiceImpl();
}
@Override
public void onCreate(){
super.onCreate();
NotificationManager currentManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

I think the real problem is with the context in the Impl. Can I even
get an application context from the impl? Should this be passed to the
service from the application? Can it be grabed from AndroidService?

public class AndroidServiceImpl extends IAndroidService.Stub{
public String getAndroidText(String conversation)
throws RemoteException {
// TODO Auto-generated method stub
NotificationManager currentManager = 
(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

Context context = getApplicationContext();

This is for an open source class I am teaching so I can create a
Google project tomorrow if you still want to help. That way you can
see the whole code.

On Jan 9, 2:39 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 How are you creating notification ?

 09.01.2011 22:33, Jackie G. пишет:



  Also double checked and it is hitting the breakpoint.

  On Jan 9, 11:35 am, Kostya Vasilyevkmans...@gmail.com  wrote:
  I don't see code in getAndroidText that would initialize notification.

  It should be something like:

  notification = new Notification(R.drawable.status_icon, Hello,
  System.currentTimeMillis());

  And does getAndroidText really get called? You can verify by setting a
  breakpoint.

  -- Kostya

  09.01.2011 19:03, Jackie G. пишет:

  Kostya,
  Thanks for the advice I did as you have said and everything compiles.
  There is still a problem, however, the notification manager does not
  show the updates I am expecting.
  Here is my Service Impl
  public class AndroidServiceImpl extends IAndroidService.Stub{
            public String getAndroidText(String conversation)
                    throws RemoteException {
                // TODO Auto-generated method stub
                NotificationManager currentManager = (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
                Context context = getApplicationContext();
                CharSequence contentTitle = Sogeti;
                CharSequence contentText = This is a message;
                Intent notificationIntent = new
  Intent(AndroidService.this, AndroidServiceImpl.class);
                PendingIntent contentIntent =
  PendingIntent.getActivity(AndroidService.this, 0, notificationIntent,
  0);
                notification.setLatestEventInfo(context, contentTitle,
  contentText, contentIntent);
                currentManager.notify(NOTIFICATION_ID, notification);
                return Android Services are Fun!;
            }
        }
  And the parts of the activity that call the service...
  @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            bindService(new
  Intent(com.sogeti.walkthrough.service.ANDROID_SERVICE), serConn,
  Context.BIND_AUTO_CREATE);
            serviceBtn = (Button)findViewById(R.id.serviceBtn);
            serviceBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    callService();
                }
            });
        }
        private void callService(){
            try{
                String text = androidService.getAndroidText(Test);
                String other = test;
            }
            catch(NullPointerException npe){
                //TODO: Log Null pointer
            }
            catch(RemoteException rme){
                //TODO: log errors
            }
        }
  On Jan 8, 3:05 pm, Kostya Vasilyevkmans...@gmail.com    wrote:
  Intent(Context context, Class cls)
  needs a Context as first parameter, which
  AndroidService.AndroidServiceImpl is not :)
  I see you have a variable called context, you can probably use that,
  or use standard Java notation AndroidService.this to refer to the
  enclosing class instance, which as far as I can see, is a Service, which
  is a Context.
  -- Kostya
  08.01.2011 22:55, Jackie G. пишет:
  Hi everyone,
  I am looking for someone to help me with a simple RPC service. What I
  want to do is create a notification message once the service is
  started and every time the RPC interface is called I want to update
  the notification. Creating the notification works but when I add the
  following...
  P.S. new to GGs so sorry