Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - getSystemService error

getSystemService error

Put your problem here if it does not fit any of the other categories.

getSystemService error

Postby ablin » Sun Jan 24, 2010 3:51 pm

button3.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
exPhoneCallListener myPhoneCallListener = new exPhoneCallListener();
TelephonyManager tm = (TelephonyManager)
this.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(myPhoneCallListener, PhoneStateListener.LISTEN_CALL_STATE);
}
});

at getSystemService is error

what can i do?


I want to use a button to openclose a phoneListener.
ablin
Freshman
Freshman
 
Posts: 4
Joined: Mon Jan 11, 2010 8:59 am

Top

Postby grzegorz.zajac » Sun Jan 24, 2010 4:28 pm

Hello,

In your code, inside the onClick() method, this is not a reference to the Context object, rather it is reference to the View.OnClickListener().

As getSystemService() is Context object method, your code should be:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onClick(View v) {
  2.    exPhoneCallListener myPhoneCallListener = new exPhoneCallListener();
  3.    TelephonyManager tm = (TelephonyManager) v.getContext().getSystemService(Context.TELEPHONY_SERVICE);
  4.    tm.listen(myPhoneCallListener, PhoneStateListener.LISTEN_CALL_STATE);
  5. }
  6.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Regards,
Grzesiek
grzegorz.zajac
Developer
Developer
 
Posts: 39
Joined: Wed Feb 18, 2009 8:37 pm
Location: Krakow/Poland

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests