Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

[edited] @Extra fields should be updated when setIntent() is called #166

Description

@Brimstedt

Hello

Im using notifications to launch an activity and in this activity I have used the @extra annotation to inject my extras.

Example:

@ViewById(R.id.server)
TextView serverView;

@Extra(SERVER)
String server;

@AfterViews
protected void afterViews()
{
    serverView.setText(server);
}

@Override
protected void onPostResume()
{
    super.onPostResume();
    serverView.setText(server);
}

However, my serverView is never updated with new text during the PostResume, unless I also add:

@Override
protected void onNewIntent(Intent intent)
{
    super.onNewIntent(intent);
    server = intent.getStringExtra(TITLE);
}

Shouldnt this updating be done automatically be androidannotation?

br

Activity

  1. pyricau commented on Apr 13, 2012

    @pyricau
    Contributor

    You are perfectly right. That's a bug, we need to fix it :) .

  2. Brimstedt commented on Apr 19, 2012

    @Brimstedt
    ContributorAuthor

    So, I thought Id have a go at this, but following the instructions on https://github.com/excilys/androidannotations/wiki/InstallingEnvironment I didnt manage to get things set up..

    Probably the instructions are a little bit outdated, because naming of projects does not really match is seems, amongst other things.

    For example have not "rest-api-test-1-5" project, but i do have a functional-test-1-5-tests instead. Is this the same?

    Anyway, after a lot of fiddling, i managed to get junit to run tests, but now they fail because R is not found:

    java.lang.Error: Unresolved compilation problems: 
    R cannot be resolved to a variable
    R cannot be resolved to a variable
    R cannot be resolved to a variable
    R cannot be resolved to a variable
    
    at com.googlecode.androidannotations.test15.TouchesHandledActivity.<init>(TouchesHandledActivity.java:24)
    at com.googlecode.androidannotations.test15.TouchesHandledActivity_.<init>(TouchesHandledActivity_.java:18)
    at com.googlecode.androidannotations.test15.TouchesHandledActivityTest.setup(TouchesHandledActivityTest.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at com.xtremelabs.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:206)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    

    Not build errors reported by eclise,
    aa classes are generated fine
    android generated files are on classpath

    any ideas?
    Any chance of looking through the instructions with todays code and update it? Im unfortunately not qualified myself at this point to know whats right and wrong here :)

  3. pyricau commented on Apr 19, 2012

    @pyricau
    Contributor

    You're definitely right : the documentation is not up to date. I have to rewrite them, and that means downloading a new clean eclipse, updating to the last version of all the maven / android / etc plugins, and carefully writing down each step.

    I'll try to do that in the coming weeks, because I'd really like to get more contributions :) .

    So, you seem to have a "R" not found when running the tests with robolectric. Is the R class actually generated in the first project?

  4. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    I see, and I understand if its not top priority.

    Anyway, I got past the R problem too somehow (probably after messing with classpath, not sure :-P)

    Now everything seems fine, except when I run unit tests they freeze.

    for example the first one, has in its setup:

    public void setup() {
        activity = new TouchesHandledActivity_();
        activity.onCreate(null);
    
        mockedEvent = MotionEvent.obtain(0, 0, 0, 0f, 0f, 0);
    }
    

    when TouchesHandledActivity_.onCreate calls its super method, then everything hangs on

        setContentView(layout.clickable_widgets);
    

    any idea on this one? :)
    Tried googling it a bit but didnt find anything that helped :-P

    /L

  5. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    I also get warnings like below, is this normal?

    Warning: an error occurred while binding shadow class: ShadowBluetoothAdapter
    Warning: an error occurred while binding shadow class: ShadowBluetoothDevice
    Warning: an error occurred while binding shadow class: ShadowGeoPoint
    Warning: an error occurred while binding shadow class: ShadowItemizedOverlay
    Warning: an error occurred while binding shadow class: ShadowMapController
    Warning: an error occurred while binding shadow class: ShadowMapActivity
    Warning: an error occurred while binding shadow class: ShadowMapView
    Warning: an error occurred while binding shadow class: ShadowOverlayItem
    Warning: an error occurred while binding shadow class: ShadowZoomButtonsController

    /L

  6. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    Maybe this is a roboguice issue, it hangs on the sdk-line.. notice the comment

        // Should always work from the command line. Often fails in IDEs because they don't pass the full PATH in the environment
        try {
            Process process = Runtime.getRuntime().exec(new String[]{"which", "android"});
            String sdkPath = new BufferedReader(new InputStreamReader(process.getInputStream())).readLine();
    
  7. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    sorry for spamming the thread, but after looking at that code it will obviously not work on windows. i will investigate this a bit myself, no need fgor you to waste time right now.

  8. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    Ok, this was indeed the cause of the freeze.
    After examinigng roboguice code a bit, it came clear that setting ANDROID_HOME was sufficient and now my tests run and pass (and apparently made my phone reboot :-)

    thanks for your patiance

  9. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    I did not mean to close the issue.

  10. pyricau commented on Apr 20, 2012

    @pyricau
    Contributor

    Wow. You seem to progress quite well :) Sorry for not answering any earlier, I'm at a conference those days (Devoxx France).

    Running the tests made your phone reboot ? That's quite unexpected. Are you running the tests on your phone ?

  11. Brimstedt commented on Apr 20, 2012

    @Brimstedt
    ContributorAuthor

    No need for appologies, hope youre having a good conference!

    Now that i got things to compile and run, im halfway done with a fix of the
    original issue. :)

    /L
    On Apr 20, 2012 1:49 PM, "Pierre-Yves Ricau" <
    reply@reply.github.com>
    wrote:

    Wow. You seem to progress quite well :) Sorry for not answering any
    earlier, I'm at a conference those days (Devoxx France).

    Running the tests made your phone reboot ? That's quite unexpected. Are
    you running the tests on your phone ?


    Reply to this email directly or view it on GitHub:

    #166 (comment)

  12. Brimstedt commented on Apr 22, 2012

    @Brimstedt
    ContributorAuthor

    Ok, I sent a pull request, lets hope for the best ;-)

    Anyway, I saw this comment on the page that describes setting up dev env:

     To see your changes in the code, you have to restart the 2nd eclipse. We didn't find any better solution, but tell us if you do!
    

    I just run second eclipse in debug mode, then hot code replace will work and upon changes in code you can just clean the test projects or other projects you have in second eclipse.

  13. pyricau commented on Apr 23, 2012

    @pyricau
    Contributor

    I'll have a look at that :) .

    You're right regarding the comment, I need to clean up things there :) . Hot code replace works, but only inside methods, if you modify signatures you need to restart it. I should give JRebel a try :) .

  14. pyricau commented on May 10, 2012

    @pyricau
    Contributor

    This issue was closed by 85da1fc.

    We override setIntent(). If a user wants to reinject the extras, he should override onNewIntent() and call setIntent() from there.

    Also note that @Extra can now only be used in Activities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions