从一个活动传递到另一个活动的字符串变量 [英] string variable passing from one activity to another

查看:74
本文介绍了从一个活动传递到另一个活动的字符串变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发基于youtube视频搜索的新应用.
几乎所有部分都完成了.但我有一个问题是,我无法从一个班级到另一个班级搜索到的视频显示为视频流.

我将一个字符串变量从一个类传递到另一个类,因为视频是由一项活动决定的,而在另一项活动中进行流式传输的.我可以访问字符串变量,但它显示强制关闭错误消息.
请帮助我先生...........


i am developing a new application based on youtube video search.
almost all portions are completed. but i have one problem is that, i cant get a searched video from one class to another class which is shown a video stream.

i passed a string variable from one class to another,because the video decided by one activity and streaming at another activity. I can access the string variable but it shows force close error message.
plz help me sir...........

推荐答案

通常,您使用Intent将数据从一个活动传递到另一个活动.
Normally you pass data from one activity to another using the Intent.
Intent intent = new Intent(SearchActivity.this, VideoActivity.class);
intent.putString(VideoActivity.SEARCH_PARAMETER_KEY, searchResult);
startActivity(intent);


其中SEARCH_PARAMETER_KEY是在VideoActivity中定义的常量字符串,而searchResult是包含实际参数值的字符串.


where SEARCH_PARAMETER_KEY is a constant String defined in your VideoActivity, and searchResult is a String containing the actual parameter value.


请添加一些代码段以更好地呈现问题陈述.
Please add some code-snippet to give a better picture of Problem Statement.


这篇关于从一个活动传递到另一个活动的字符串变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆