René's URL Explorer Experiment


Title: Fix IntentBuilder startForResult by tbruyelle · Pull Request #680 · androidannotations/androidannotations · GitHub

Open Graph Title: Fix IntentBuilder startForResult by tbruyelle · Pull Request #680 · androidannotations/androidannotations

X Title: Fix IntentBuilder startForResult by tbruyelle · Pull Request #680 · androidannotations/androidannotations

Description: Related to #541 In a fragment, startActivityForResult must be called on the Fragment and not on getActivity(), or the fragment's onActivityResult will never be hit. Now IntentBuilder may have up to 3 constructors, depending on the classpath content. According to the constructor chosen, startActivityForResult() will be called on Activity, android.app.Fragment or android.support.v4.app.Fragment. From the AA user perspective, this fix is quite transparent, he just have to call MyActivity_.intent(this), whatever he's in a fragment or an activity, it will work. Generated code in case of both android.app.Fragment and android.support.v4.Fragment are presents in the classpath (true for current AA junit environment) : public static ExtendingActivity_.IntentBuilder_ intent(Context context) { return new ExtendingActivity_.IntentBuilder_(context); } public static ExtendingActivity_.IntentBuilder_ intent(android.app.Fragment fragment) { return new ExtendingActivity_.IntentBuilder_(fragment); } public static ExtendingActivity_.IntentBuilder_ intent(android.support.v4.app.Fragment fragment) { return new ExtendingActivity_.IntentBuilder_(fragment); } public static class IntentBuilder_ { private Context context_; private final Intent intent_; private android.app.Fragment fragment_; private android.support.v4.app.Fragment fragmentSupport_; public IntentBuilder_(Context context) { context_ = context; intent_ = new Intent(context, ExtendingActivity_.class); } public IntentBuilder_(android.app.Fragment fragment) { fragment_ = fragment; context_ = fragment.getActivity(); intent_ = new Intent(context_, ExtendingActivity_.class); } public IntentBuilder_(android.support.v4.app.Fragment fragment) { fragmentSupport_ = fragment; context_ = fragment.getActivity(); intent_ = new Intent(context_, ExtendingActivity_.class); } public Intent get() { return intent_; } public ExtendingActivity_.IntentBuilder_ flags(int flags) { intent_.setFlags(flags); return this; } public void start() { context_.startActivity(intent_); } public void startForResult(int requestCode) { if (fragmentSupport_!= null) { fragmentSupport_.startActivityForResult(intent_, requestCode); } else { if (fragment_!= null) { fragment_.startActivityForResult(intent_, requestCode); } else { if (context_ instanceof Activity) { ((Activity) context_).startActivityForResult(intent_, requestCode); } else { context_.startActivity(intent_); } } } } } Notes : I didn't find proper method to test if a class is present in the classpath. so I used Class.forName(). Tell me if I miss something. I tested the feature in a test project, and the generated code is well updated according to android.app.Fragment or android.support.v4.app.Fragment are present or not in the classpath. But I didn't manage to create a junit for that. The only tests I wrote are compile tests with fragments class which use the new intent() methods.

Open Graph Description: Related to #541 In a fragment, startActivityForResult must be called on the Fragment and not on getActivity(), or the fragment's onActivityResult will never be hit. Now IntentBuilder may have u...

X Description: Related to #541 In a fragment, startActivityForResult must be called on the Fragment and not on getActivity(), or the fragment's onActivityResult will never be hit. Now IntentBuilder may ha...

Opengraph URL: https://github.com/androidannotations/androidannotations/pull/680

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c9798cbf-4d26-9bad-d0ef-8eca77101c51
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE0E0:2D823:1012B57:167E607:6A61B892
html-safe-nonceab4429b607b6ebd4050d212d659a62e32bd6bb4f0f3dddf121ee2561d7d36002
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEUwOjJEODIzOjEwMTJCNTc6MTY3RTYwNzo2QTYxQjg5MiIsInZpc2l0b3JfaWQiOiI0OTI1MDE4MDc1MDI3MzIzMDI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb3b3ea0a94eb8da437c74920dd79e7eab7f7fd2723af4687a7abbe5635fd227a
hovercard-subject-tagpull_request:7194451
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/androidannotations/androidannotations/pull/680/files
twitter:imagehttps://avatars.githubusercontent.com/u/92280?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/92280?s=400&v=4
og:image:altRelated to #541 In a fragment, startActivityForResult must be called on the Fragment and not on getActivity(), or the fragment's onActivityResult will never be hit. Now IntentBuilder may have u...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None6f4633bcf01c1ad14b73fd07dd39ac31d61f3d3c2578ee08ec1792b7b351eeb9
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/androidannotations/androidannotations git https://github.com/androidannotations/androidannotations.git
octolytics-dimension-user_id1315313
octolytics-dimension-user_loginandroidannotations
octolytics-dimension-repository_id3116751
octolytics-dimension-repository_nwoandroidannotations/androidannotations
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3116751
octolytics-dimension-repository_network_root_nwoandroidannotations/androidannotations
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseac296ae7f21856f1f92adbad22f870b6fbb4b907
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/androidannotations/androidannotations/pull/680/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fandroidannotations%2Fandroidannotations%2Fpull%2F680%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fandroidannotations%2Fandroidannotations%2Fpull%2F680%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=androidannotations%2Fandroidannotations
Reloadhttps://github.com/androidannotations/androidannotations/pull/680/files
Reloadhttps://github.com/androidannotations/androidannotations/pull/680/files
Reloadhttps://github.com/androidannotations/androidannotations/pull/680/files
Please reload this pagehttps://github.com/androidannotations/androidannotations/pull/680/files
androidannotations https://github.com/androidannotations
androidannotationshttps://github.com/androidannotations/androidannotations
Notifications https://github.com/login?return_to=%2Fandroidannotations%2Fandroidannotations
Fork 2.3k https://github.com/login?return_to=%2Fandroidannotations%2Fandroidannotations
Star 11k https://github.com/login?return_to=%2Fandroidannotations%2Fandroidannotations
Code https://github.com/androidannotations/androidannotations
Issues 50 https://github.com/androidannotations/androidannotations/issues
Pull requests 0 https://github.com/androidannotations/androidannotations/pulls
Actions https://github.com/androidannotations/androidannotations/actions
Wiki https://github.com/androidannotations/androidannotations/wiki
Security and quality 0 https://github.com/androidannotations/androidannotations/security
Insights https://github.com/androidannotations/androidannotations/pulse
Code https://github.com/androidannotations/androidannotations
Issues https://github.com/androidannotations/androidannotations/issues
Pull requests https://github.com/androidannotations/androidannotations/pulls
Actions https://github.com/androidannotations/androidannotations/actions
Wiki https://github.com/androidannotations/androidannotations/wiki
Security and quality https://github.com/androidannotations/androidannotations/security
Insights https://github.com/androidannotations/androidannotations/pulse
DayShttps://github.com/DayS
androidannotations:develophttps://github.com/androidannotations/androidannotations/tree/develop
tbruyelle:541_FragmentStartActivityForResulthttps://github.com/tbruyelle/androidannotations/tree/541_FragmentStartActivityForResult
Conversation 4 https://github.com/androidannotations/androidannotations/pull/680
Commits 2 https://github.com/androidannotations/androidannotations/pull/680/commits
Checks 0 https://github.com/androidannotations/androidannotations/pull/680/checks
Files changed https://github.com/androidannotations/androidannotations/pull/680/files
Please reload this pagehttps://github.com/androidannotations/androidannotations/pull/680/files
Fix IntentBuilder startForResult https://github.com/androidannotations/androidannotations/pull/680/files#top
Show all changes 2 commits https://github.com/androidannotations/androidannotations/pull/680/files
d4f72ee Fix IntentBuilder startForResult tbruyelle Jul 26, 2013 https://github.com/androidannotations/androidannotations/pull/680/commits/d4f72ee5eb85befc19ab173cbeeb5d82f9e2399f
1239f62 Use new method to check class in classpath tbruyelle Sep 3, 2013 https://github.com/androidannotations/androidannotations/pull/680/commits/1239f624969cf725c2315fafd3e5bec8ca286ba7
Clear filters https://github.com/androidannotations/androidannotations/pull/680/files
Please reload this pagehttps://github.com/androidannotations/androidannotations/pull/680/files
Please reload this pagehttps://github.com/androidannotations/androidannotations/pull/680/files
AndroidAnnotationProcessor.java https://github.com/androidannotations/androidannotations/pull/680/files#diff-85d00e91b8b7f648293fac94a61eb4d6db4011e414e81795301ccff137fb9679
APTCodeModelHelper.java https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
EActivityProcessor.java https://github.com/androidannotations/androidannotations/pull/680/files#diff-76121b8d463abf52349ec43551b3cb14aa0c9e156c83bb6789e0c04ebbeb3f15
EServiceProcessor.java https://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
StartActivityFragment.java https://github.com/androidannotations/androidannotations/pull/680/files#diff-928c3c89d1c419e4a5a6e6a818324a372ee73aeb5974c1c6b7d081b5e88fa311
StartActivityFragmentSupport.java https://github.com/androidannotations/androidannotations/pull/680/files#diff-9a59e05ecb18b9495f66019dd476803c639e1193f1b4b55bd4ad45428720fd4e
...s/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.javahttps://github.com/androidannotations/androidannotations/pull/680/files#diff-85d00e91b8b7f648293fac94a61eb4d6db4011e414e81795301ccff137fb9679
View file https://github.com/tbruyelle/androidannotations/blob/1239f624969cf725c2315fafd3e5bec8ca286ba7/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/androidannotations/androidannotations/pull/680/{{ revealButtonHref }}
https://github.com/androidannotations/androidannotations/pull/680/files#diff-85d00e91b8b7f648293fac94a61eb4d6db4011e414e81795301ccff137fb9679
https://github.com/androidannotations/androidannotations/pull/680/files#diff-85d00e91b8b7f648293fac94a61eb4d6db4011e414e81795301ccff137fb9679
...ns/androidannotations/src/main/java/org/androidannotations/helper/APTCodeModelHelper.javahttps://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
View file https://github.com/tbruyelle/androidannotations/blob/1239f624969cf725c2315fafd3e5bec8ca286ba7/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/APTCodeModelHelper.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/androidannotations/androidannotations/pull/680/{{ revealButtonHref }}
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
https://github.com/androidannotations/androidannotations/pull/680/files#diff-7caf69d84850bbedde5bfe5f4681fdfd42b1310a58e5b605e46b0387cb494c1b
...ndroidannotations/src/main/java/org/androidannotations/processing/EActivityProcessor.javahttps://github.com/androidannotations/androidannotations/pull/680/files#diff-76121b8d463abf52349ec43551b3cb14aa0c9e156c83bb6789e0c04ebbeb3f15
View file https://github.com/tbruyelle/androidannotations/blob/1239f624969cf725c2315fafd3e5bec8ca286ba7/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/EActivityProcessor.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/androidannotations/androidannotations/pull/680/{{ revealButtonHref }}
https://github.com/androidannotations/androidannotations/pull/680/files#diff-76121b8d463abf52349ec43551b3cb14aa0c9e156c83bb6789e0c04ebbeb3f15
https://github.com/androidannotations/androidannotations/pull/680/files#diff-76121b8d463abf52349ec43551b3cb14aa0c9e156c83bb6789e0c04ebbeb3f15
...androidannotations/src/main/java/org/androidannotations/processing/EServiceProcessor.javahttps://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
View file https://github.com/tbruyelle/androidannotations/blob/1239f624969cf725c2315fafd3e5bec8ca286ba7/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/EServiceProcessor.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/androidannotations/androidannotations/pull/680/{{ revealButtonHref }}
https://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
https://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
https://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
https://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
https://github.com/androidannotations/androidannotations/pull/680/files#diff-ca73083f2d33b22c364aa6007190a7216efcc559bac02fc6fece9133e40752c6
...test-1-5/src/main/java/org/androidannotations/test15/efragment/StartActivityFragment.javahttps://github.com/androidannotations/androidannotations/pull/680/files#diff-928c3c89d1c419e4a5a6e6a818324a372ee73aeb5974c1c6b7d081b5e88fa311
View file https://github.com/tbruyelle/androidannotations/blob/1239f624969cf725c2315fafd3e5bec8ca286ba7/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/efragment/StartActivityFragment.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/androidannotations/androidannotations/pull/680/{{ revealButtonHref }}
...5/src/main/java/org/androidannotations/test15/efragment/StartActivityFragmentSupport.javahttps://github.com/androidannotations/androidannotations/pull/680/files#diff-9a59e05ecb18b9495f66019dd476803c639e1193f1b4b55bd4ad45428720fd4e
View file https://github.com/tbruyelle/androidannotations/blob/1239f624969cf725c2315fafd3e5bec8ca286ba7/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/efragment/StartActivityFragmentSupport.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/androidannotations/androidannotations/pull/680/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.