【发布时间】:2018-09-02 09:08:44
【问题描述】:
所以我是 android 和 java 的新手,我知道我应该在有意图的活动之间移动。
Intent randomintent = new Intent(profile.this, loggedactivity.class);
randomintent .putString("name", namestring);
startActivity(randomintent);
问题是,我还有一个函数,我希望它在此意图将用户带到另一个活动之前执行。所以我的代码看起来像这样。
btnUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
uploadImage();
//this uploads the image, it works without the intent i added
infosendstuff();
//this should be executed after the image is uploaded and stores the image link to a database (also works)
Intent randomintent = new Intent(profile.this, loggedactivity.class);
randomintent .putString("name", namestring);
startActivity(randomintent);
}
});
问题似乎是意图,在使用时,它忽略了它上面的其他两个功能,即上传图片并存储该图片的链接。 目标是上传图片,一旦完成,获取链接,通过意图(使用捆绑包)将链接发送到另一个活动,仅此而已。
【问题讨论】:
-
请分享
uploadImage()和infosendstuff()的代码 -
您的捆绑包似乎无处可去。您是否考虑过使用
putExtra()? -
@jake 我试过了,但它也可以这样工作!
-
但是当您在另一个
Activity中检索它时,您是否获得了价值?并请发布uploadImage()infosendstuff()方法
标签: java android function android-studio android-intent