NFC - missing method getParcelableExtra( ... )

by Lars Nielsen Lind » Tue, 15 Mar 2011 06:21:10 GMT


Sponsored Links
 Hi,

I have used the following code which is published on various sites:


PendingIntent intent =
PendingIntent.getActivity(this.getApplicationContext(), 0,new
Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),0);

NfcAdapter.getDefaultAdapter(this).enableForegroundDispatch(this,intent,
null, null);

Tag tag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);


Here is the error message:

The method getParcelableExtra(String) is undefined for the type
PendingIntent

Anyone that knows why I can't call getParcelable(....) as shown above?

Thanks,

Lars


-- 



Re: NFC - missing method getParcelableExtra( ... )

by Mark Murphy » Tue, 15 Mar 2011 06:24:51 GMT


 You can call getParcelableExtra() on an Intent, not on a PendingIntent.

On Mon, Mar 14, 2011 at 6:21 PM, Lars Nielsen Lind





-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training in Oslo:  http://bit.ly/fjBo24 

-- 


Sponsored Links


Other Threads

1. which junit to use when creating reusable library for Android apps?

For more sophisticated apps with a large number of team members and
contributors, running unit tests in an emulator may be impractical.
Emulator requires some sort of a some sort of a graphics/windowing setup.
Usually though (at least in my experience), unit tests are run on an
integrated build machines running things like Hudson or Cruise Control.
Most of the time, these machines are not or can not be set up to run a
windowing system especially when running linux.  It would be very cool if
there was a way to get around the the true emulator for unit test purposes.









--~--~---------~--~----~------------~-------~--~----~

2. Has anyone gotten the Speech Recognition demo to work in the 1.5SDK?

Has anyone gotten Speech Recognition (RecognizeIntent) to work in the
Android 1.5 SDK? Whenever I try to start the Intent my application
crashes and I get this error:

E/AndroidRuntime(  714): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime(  714): android.content.ActivityNotFoundException: No
Activity found to handle Intent
{ action=android.speech.action.RECOGNIZE_SPEECH (has extras) }
E/AndroidRuntime(  714):        at
android.app.Instrumentation.checkStartActivityResult
(Instrumentation.java:1484)
E/AndroidRuntime(  714):        at
android.app.Instrumentation.execStartActivity(Instrumentation.java:
1454)
E/AndroidRuntime(  714):        at
android.app.Activity.startActivityForResult(Activity.java:2656)
E/AndroidRuntime(  714):        at
com.shuanwang.tinkertoy.Tinkertoy.startRecognition(Tinkertoy.java:49)
E/AndroidRuntime(  714):        at com.shuanwang.tinkertoy.Tinkertoy
$1.onClick(Tinkertoy.java:21)
E/AndroidRuntime(  714):        at android.view.View.performClick(View.java:
2179)
E/AndroidRuntime(  714):        at android.view.View.onTouchEvent(View.java:
3828)
E/AndroidRuntime(  714):        at android.widget.TextView.onTouchEvent
(TextView.java:6291)
E/AndroidRuntime(  714):        at android.view.View.dispatchTouchEvent
(View.java:3368)
E/AndroidRuntime(  714):        at android.view.ViewGroup.dispatchTouchEvent
(ViewGroup.java:863)
E/AndroidRuntime(  714):        at android.view.ViewGroup.dispatchTouchEvent
(ViewGroup.java:863)
E/AndroidRuntime(  714):        at android.view.ViewGroup.dispatchTouchEvent
(ViewGroup.java:863)
E/AndroidRuntime(  714):        at android.view.ViewGroup.dispatchTouchEvent
(ViewGroup.java:863)
E/AndroidRuntime(  714):        at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
E/AndroidRuntime(  714):        at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent
(PhoneWindow.java:1197)
E/AndroidRuntime(  714):        at android.app.Activity.dispatchTouchEvent
(Activity.java:1993)
E/AndroidRuntime(  714):        at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
E/AndroidRuntime(  714):        at android.view.ViewRoot.handleMessage
(ViewRoot.java:1525)
E/AndroidRuntime(  714):        at android.os.Handler.dispatchMessage
(Handler.java:99)
E/AndroidRuntime(  714):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  714):        at android.app.ActivityThread.main
(ActivityThread.java:3948)
E/AndroidRuntime(  714):        at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime(  714):        at java.lang.reflect.Method.invoke
(Method.java:521)
E/AndroidRuntime(  714):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime(  714):        at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:540)
E/AndroidRuntime(  714):        at dalvik.system.NativeStart.main(Native
Method)

supports speech recognition the intent. If there isn't an app, how do
we get it working in the SDK? Is there If anyone could explain what
I'm missing or could post some sample code for Speech Recognition
that'd be a lot of help. Thanks.

--~--~---------~--~----~------------~-------~--~----~

3. How Do Widgets Work

4. how convert bitmap to byte array?

5. Plugin 0.9 ADT with Eclipse (G4.3.2) on WIN XP SP3 problem

6. HEAP size increase on every Http post request

7. error error "Could not find method javax.activation.DataHandler.getContent, referenced from method javax.mail.internet.MimeMessage.getContent"