У меня возникла проблема, когда моя кнопка не позволяла мне открыть указанный URL. Просто сила закрывается всякий раз, когда я открываю это действие. Вот мой код;
public class TemakiActivity extends Activity {
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contentviewer);
ImageView imageView = (ImageView) findViewById(R.id.videolink);
imageView.setImageResource(R.drawable.videothumb);
addListenerOnButton();
}
public void addListenerOnButton() {
button = (Button) findViewById(R.id.videolink);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com"));
startActivity(browserIntent);
}
});
TextView helloTxt = (TextView)findViewById(R.id.ingredientslister);
helloTxt.setText(readTxt());
}
private String readTxt(){
InputStream inputStream = getResources().openRawResource(R.raw.temakiingredients);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
try {
i = inputStream.read();
while (i != -1)
{
byteArrayOutputStream.write(i);
i = inputStream.read();
}
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return byteArrayOutputStream.toString();
}
}
Когда я открываю это действие, оно просто принудительно закрывается! Проблема, кажется, с кнопкой, я не могу заставить его работать, какие-либо решения?