I was attempting to rename/refactor my package name for my app. It didn't work out well, so I deleted and imported the older working version.
But after I did this, when I tried to test on my phone the app keeps crashing (It works fine before). It works fine on the emulator though. How can I fix this?
EDITED:
The logcat:
Can anyone please help? How do I fix this? Thank you.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sg.rp.sdma.intake3.lab05"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/sqlauncher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="sg.rp.sdma.intake3.lab05.OverviewActivity"
android:screenOrientation="portrait"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="sg.rp.sdma.intake3.lab05.SpellingList"
android:label="#string/action_viewslist"
android:screenOrientation="portrait"
android:parentActivityName="sg.rp.sdma.intake3.lab05.OverviewActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sg.rp.sdma.intake3.lab05.OverviewActivity" />
</activity>
<activity
android:name="sg.rp.sdma.intake3.lab05.EditWordActivity"
android:label="#string/title_activity_edit_idea"
android:screenOrientation="portrait"
android:parentActivityName="sg.rp.sdma.intake3.lab05.SpellingList" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sg.rp.sdma.intake3.lab05.SpellingList" />
</activity>
<activity
android:name="sg.rp.sdma.intake3.lab05.SpellRecord"
android:screenOrientation="portrait"
android:label="#string/title_activity_record" >
</activity>
<activity
android:name="sg.rp.sdma.intake3.lab05.QuizActivity"
android:screenOrientation="portrait"
android:label="#string/title_activity_quiz"
android:parentActivityName="sg.rp.sdma.intake3.lab05.SpellingList" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="sg.rp.sdma.intake3.lab05.SpellingList" />
</activity>
<activity
android:name="sg.rp.sdma.intake3.lab05.SpellRecordActivity"
android:screenOrientation="portrait"
android:label="#string/title_activity_spell_record" >
</activity>
<activity
android:name="sg.rp.sdma.intake3.lab05.ScoreActivity"
android:screenOrientation="portrait"
android:label="#string/title_activity_score" >
</activity>
</application>
OverViewActivity:
package sg.rp.sdma.intake3.lab05;
import java.util.Random;
import sg.rp.sdma.intake3.lab05.R;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
public class OverviewActivity extends Activity {
String eYo2;
int myCD;
int mySCORE;
int ideaslth;
String rantitle;
int CId;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_overview);
Button btnNew = (Button) findViewById(R.id.buttonAdd);
btnNew.setBackgroundResource(R.drawable.blackbtntrans);
Button btnTest = (Button) findViewById(R.id.buttonTest);
btnTest.setBackgroundResource(R.drawable.blackbtntrans);
btnTest.setClickable(false);
btnTest.setVisibility(View.INVISIBLE);
loadSavedPreferences();
btnNew.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
String title = ((EditText)
findViewById(R.id.editTextTitle)).getText().toString();
if (!title.matches("")){
Ideas i = new Ideas(OverviewActivity.this);
//String title = ((EditText)findViewById(R.id.editTextTitle)).getText().toString();
eYo2 = title;
String description = ((EditText)
findViewById(R.id.editTextDescription)).getText().toString();
i.addIdea(new Idea(0, title, description, 0));
/*Toast.makeText(getApplicationContext(), ""+ title + " successfully added",
Toast.LENGTH_LONG).show();*/
//reload();
Intent i4 = new Intent(OverviewActivity.this,
SpellRecordActivity.class);
i4.putExtra("dataN", eYo2);
/*Toast.makeText(getApplicationContext(), ""+ eYo2 + " placed in bundle",
Toast.LENGTH_LONG).show();*/
Log.d("hah es", "put extra succeeded");
startActivityForResult(i4, 1);
}
else {
Toast.makeText(getApplicationContext(), "Please type a word before adding",
Toast.LENGTH_LONG).show();
}
}
}
);
btnTest.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
if (ideaslth > 0) {
Intent i0 = new Intent(OverviewActivity.this,
QuizActivity.class);
Log.d("hah id", "int declared");
i0.putExtra("dataR", rantitle);
Log.d("hah es2", "put extra2 succeeded");
myCD = 9;
mySCORE = 0;
savePreferences("Score", mySCORE);
savePreferences("countDown", myCD);
startActivityForResult(i0, 1);
}
else {
Toast.makeText(getApplicationContext(), "Your list is currently empty",
Toast.LENGTH_LONG).show();
}
}
});
ShowExistingIdeas();
}
public void reload() {
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
}
private void RandomTitle() {
Idea[] ideas = new Ideas(this).getAllIdeas();
if(ideas != null && ideas.length > 0)
{
for(int index = 0; index < ideas.length; index++)
{
Random r = new Random();
int in1=r.nextInt(ideas.length) + 0;
//CId = in1;
rantitle = (ideas[in1].getTitle());
Log.d("hah es2", "lets see" + rantitle);
}
}
}
private void ShowExistingIdeas() {
Idea[] ideas = new Ideas(this).getAllIdeas();
ideaslth = ideas.length;
if(ideas != null && ideas.length > 0)
{
for(int index = 0; index < ideas.length; index++)
{
Button ideaButton = new Button(this);
ideaButton.setText(ideas[index].getTitle());
ideaButton.setTextColor(getResources().getColor(R.color.orange));
ideaButton.setBackgroundResource(R.drawable.wordbtn);
final int id = ideas[index].getId();
ideaButton.setTag(id);
RandomTitle();
ideaButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(OverviewActivity.this,
EditWordActivity.class);
i.putExtra("id", id);
startActivityForResult(i, 0);
}
});
((LinearLayout) findViewById(R.id.LinearLayout2)).
addView(ideaButton);
}
}
}
#Override
protected void onActivityResult( int aRequestCode, int aResultCode, Intent aData) {
reload();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.overview, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.slist:
Intent il = new Intent(OverviewActivity.this,
SpellingList.class);
startActivityForResult(il,1);
break;
case R.id.etest:
if (ideaslth > 0) {
Intent i0 = new Intent(OverviewActivity.this,
QuizActivity.class);
Log.d("hah id", "int declared");
i0.putExtra("dataR", rantitle);
Log.d("hah es2", "put extra2 succeeded");
myCD = 9;
mySCORE = 0;
savePreferences("Score", mySCORE);
savePreferences("countDown", myCD);
startActivityForResult(i0, 1);
}
else {
Toast.makeText(getApplicationContext(), "Your list is currently empty",
Toast.LENGTH_LONG).show();
}
break;
case R.id.dict:
String url = "http://www.dictionary.com";
Intent idict = new Intent(Intent.ACTION_VIEW);
idict.setData(Uri.parse(url));
if (AppStatus.getInstance(this).isOnline(this)) {
startActivity(idict);
} else {
Toast.makeText(this,"Please connect to the internet",8000).show();
}
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
private void loadSavedPreferences(){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Integer countdown = sharedPreferences.getInt("countDown", 9);
myCD = countdown;
Integer score = sharedPreferences.getInt("Score", 0);
mySCORE = score;
}
private void savePreferences(String key, int value) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = sharedPreferences.edit();
editor.putInt(key, value);
editor.commit();
}
}
Related
My Android TV app only works on Android TV Emulator (Android Studio).
When I install the application on my tv box, the application crashes
here is my Androidmanifest and my activity
Androidmanifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.tvonhd.uniplaytvbox">
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.ErrorActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.VideoDetailsActivity2" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.VideoDetailsActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.SignUpActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.PlayerActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.LoginActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.ItemGenreActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.ItemCountryActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.ActivationActivity" />
<activity android:name="com.tvonhd.uniplaytvbox.ui.activity.SearchActivity" />
<activity
android:name="com.tvonhd.uniplaytvbox.ui.activity.LeanbackActivity"
android:theme="#style/AppTheme" />
<activity
android:name="com.tvonhd.uniplaytvbox.ui.activity.SplashScreenActivity"
android:banner="#drawable/ic_launcher_tv"
android:icon="#drawable/ic_launcher_tv"
android:roundIcon="#drawable/ic_launcher_tv"
android:logo="#drawable/ic_launcher_tv">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.tvonhd.uniplaytvbox.ui.activity.LoginChooserActivity"
android:screenOrientation="fullSensor"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity android:name="com.tvonhd.uniplaytvbox.MainActivity" />
</application>
</manifest>
here is my activity
activity:
```
package com.tvonhd.uniplaytvbox.fragments;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.fragment.app.FragmentManager;
import androidx.leanback.app.RowsSupportFragment;
import androidx.leanback.widget.ArrayObjectAdapter;
import androidx.leanback.widget.HeaderItem;
import androidx.leanback.widget.ListRow;
import androidx.leanback.widget.ListRowPresenter;
import androidx.leanback.widget.OnItemViewClickedListener;
import androidx.leanback.widget.OnItemViewSelectedListener;
import androidx.leanback.widget.Presenter;
import androidx.leanback.widget.Row;
import androidx.leanback.widget.RowPresenter;
import com.tvonhd.uniplaytvbox.Config;
import com.tvonhd.uniplaytvbox.NetworkInst;
import com.tvonhd.uniplaytvbox.utils.PreferenceUtils;
import com.tvonhd.uniplaytvbox.R;
import com.tvonhd.uniplaytvbox.database.DatabaseHelper;
import com.tvonhd.uniplaytvbox.model.Channel;
import com.tvonhd.uniplaytvbox.model.HomeContent;
import com.tvonhd.uniplaytvbox.model.VideoContent;
import com.tvonhd.uniplaytvbox.network.RetrofitClient;
import com.tvonhd.uniplaytvbox.network.api.HomeApi;
import com.tvonhd.uniplaytvbox.ui.BackgroundHelper;
import com.tvonhd.uniplaytvbox.ui.activity.ErrorActivity;
import com.tvonhd.uniplaytvbox.ui.activity.LeanbackActivity;
import com.tvonhd.uniplaytvbox.ui.activity.PlayerActivity;
import com.tvonhd.uniplaytvbox.ui.activity.VideoDetailsActivity;
import com.tvonhd.uniplaytvbox.ui.presenter.CardPresenter;
import com.tvonhd.uniplaytvbox.ui.presenter.SliderCardPresenter;
import com.tvonhd.uniplaytvbox.ui.presenter.TvPresenter;
import com.tvonhd.uniplaytvbox.utils.PaidDialog;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
public class HomeFragment extends RowsSupportFragment {
private BackgroundHelper bgHelper;
private ArrayObjectAdapter rowsAdapter;
private CardPresenter cardPresenter;
private View v;
private LeanbackActivity activity;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bgHelper = new BackgroundHelper(getActivity());
activity = (LeanbackActivity) getActivity();
activity.showLogo();
setOnItemViewClickedListener(getDefaultItemViewClickedListener());
setOnItemViewSelectedListener(getDefaultItemSelectedListener());
if (new NetworkInst(activity).isNetworkAvailable()) {
loadHomeContent();
} else {
Intent intent = new Intent(activity, ErrorActivity.class);
startActivity(intent);
activity.finish();
}
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
v = super.onCreateView(inflater, container, savedInstanceState);
return v;
}
private void loadHomeContent() {
final SpinnerFragment mSpinnerFragment = new SpinnerFragment();
final FragmentManager fm = getFragmentManager();
fm.beginTransaction().add(R.id.custom_frame_layout, mSpinnerFragment).commit();
Retrofit retrofit = RetrofitClient.getRetrofitInstance();
HomeApi api = retrofit.create(HomeApi.class);
Call<List<HomeContent>> call = api.getHomeContent(Config.API_KEY);
call.enqueue(new Callback<List<HomeContent>>() {
#Override
public void onResponse(Call<List<HomeContent>> call, Response<List<HomeContent>> response) {
if (response.isSuccessful()) {
List<HomeContent> homeContents = response.body();
//Log.d("size:", homeContents.size()+"");
if (homeContents.size() > 0) {
loadRows(homeContents);
} else {
Toast.makeText(getContext(), getResources().getString(R.string.no_data_found), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getContext(), response.errorBody().toString(), Toast.LENGTH_SHORT).show();
}
// hide the spinner
fm.beginTransaction().remove(mSpinnerFragment).commitAllowingStateLoss();
}
#Override
public void onFailure(Call<List<HomeContent>> call, Throwable t) {
t.printStackTrace();
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
// hide the spinner
getFragmentManager().beginTransaction().remove(mSpinnerFragment).commit();
}
});
}
private void loadRows(List<HomeContent> homeContents) {
rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
cardPresenter = new CardPresenter();
SliderCardPresenter sliderCardPresenter = new SliderCardPresenter();
TvPresenter tvPresenter = new TvPresenter();
int i;
for (i = 0; i < homeContents.size(); i++) {
ArrayObjectAdapter listRowAdapter;
HeaderItem header;
if (i == 0) {
// load slider
listRowAdapter = new ArrayObjectAdapter(sliderCardPresenter);
header = new HeaderItem(i, "");
} else if (i == 1) {
//load tv layout
listRowAdapter = new ArrayObjectAdapter(tvPresenter);
header = new HeaderItem(i, homeContents.get(i).getTitle());
} else {
listRowAdapter = new ArrayObjectAdapter(cardPresenter);
header = new HeaderItem(i, homeContents.get(i).getTitle());
}
//for (int j = 0; j < NUM_COLS; j++) {
for (int j = 0; j < homeContents.get(i).getContent().size(); j++) {
VideoContent videoContent = homeContents.get(i).getContent().get(j);
if (homeContents.get(i).getType().equalsIgnoreCase("tv")) {
videoContent.setType("tv");
} else if (homeContents.get(i).getType().equalsIgnoreCase("movie")) {
videoContent.setType("movie");
} else if (homeContents.get(i).getType().equalsIgnoreCase("tvseries")) {
videoContent.setType("tvseries");
} else if (homeContents.get(i).getType().equalsIgnoreCase("slider")) {
if (videoContent.getIsTvseries().equals("1")) {
videoContent.setType("tvseries");
} else if (videoContent.getIsTvseries().equals("0")) {
videoContent.setType("movie");
}
}
listRowAdapter.add(videoContent);
}
rowsAdapter.add(new ListRow(header, listRowAdapter));
}
setAdapter(rowsAdapter);
setCustomPadding();
}
private void setCustomPadding() {
// getView().setPadding(Utils.dpToPx(-24, getContext()), Utils.dpToPx(70, getContext()), 0, 0);
}
// click listener
private OnItemViewClickedListener getDefaultItemViewClickedListener() {
return new OnItemViewClickedListener() {
#Override
public void onItemClicked(Presenter.ViewHolder viewHolder, Object o,
RowPresenter.ViewHolder viewHolder2, Row row) {
VideoContent videoContent = (VideoContent) o;
String status = new DatabaseHelper(getContext()).getActiveStatusData().getStatus();
if (videoContent.getType().equals("tv")) {
if (videoContent.getIsPaid().equals("1")) {
if (PreferenceUtils.isValid(getActivity())) {
if (status.equals("active")) {
Intent intent = new Intent(getActivity(), PlayerActivity.class);
intent.putExtra("id", videoContent.getId());
intent.putExtra("videoType", videoContent.getStreamFrom());
intent.putExtra("streamUrl", videoContent.getStreamUrl());
startActivity(intent);
} else {
//subscription is not active
//new PaidDialog(getActivity()).showPaidContentAlertDialog();
PaidDialog dialog = new PaidDialog(getContext());
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.show();
}
} else {
//saved data is not valid, because it was saved more than 2 hours ago
PreferenceUtils.updateSubscriptionStatus(getActivity());
}
} else {
Intent intent = new Intent(getActivity(), PlayerActivity.class);
intent.putExtra("id", videoContent.getId());
intent.putExtra("videoType", videoContent.getStreamFrom());
intent.putExtra("streamUrl", videoContent.getStreamUrl());
startActivity(intent);
}
} else {
Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);
intent.putExtra("id", videoContent.getId());
intent.putExtra("type", videoContent.getType());
intent.putExtra("thumbImage", videoContent.getThumbnailUrl());
startActivity(intent);
}
}
};
}
//listener for setting blur background each time when the item will select.
protected OnItemViewSelectedListener getDefaultItemSelectedListener() {
return new OnItemViewSelectedListener() {
public void onItemSelected(Presenter.ViewHolder itemViewHolder, final Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
if (item instanceof VideoContent) {
bgHelper = new BackgroundHelper(getActivity());
bgHelper.prepareBackgroundManager();
bgHelper.startBackgroundTimer(((VideoContent) item).getPosterUrl());
} else if (item instanceof Channel) {
bgHelper = new BackgroundHelper(getActivity());
bgHelper.prepareBackgroundManager();
bgHelper.startBackgroundTimer(((Channel) item).getPosterUrl());
}
}
};
}
}
My Android TV app only works on Android TV Emulator (Android Studio). When I install the application on my TV Box, the application crashes. this error is caused by leanback?
Thanks for your help
Make android.software.leanback feature required false.
<uses-feature
android:name="android.software.leanback"
android:required="false" />
If you set the required attribute value to true, your app will run only on devices that use the Leanback UI.
I want after a click on the OK button the MenuActivity to be shown. I have already searched on the Internet to find an answer and tried everything. I haave the activity declared in the AndroidManifest and I also tried to use Intent(this, MenuActivity.class) and also the one with the action inside but it doesn't work.
MainActivity:
package com.jamesjohnson.chronos;
import android.app.AlertDialog;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.*;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.jamesjohnson.chronos.R;
public class MainActivity extends ActionBarActivity implements OnClickListener {
private static final String TAG = "MainActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.setTitle("Willkommen");
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(this);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
switch(id) {
case R.id.action_mainmenu:
startActivity(new Intent("com.jamesjohnson.chronos.MenuActivity"));
return true;
case R.id.action_settings:
showMessageBox("Es gibt leider noch keine Einstellungen. Wir arbeiten daran!", true, true);
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onClick(View v) {
try {
Intent intent = new Intent(MainActivity.this, MenuActivity.class);
Context ctx = this;
intent.setClassName(ctx, "com.jamesjohnson.chronos.MenuActivity");
intent.setAction("com.jamesjohnson.chronos.MenuActivity");
if ((intent.getAction() == "com.jamesjohnson.chronos.MenuActivity") || (intent.getClass() != null)) {
MainActivity.this.startActivity(intent);
showMessageBox("Button has been pressed " + intent.toString(), true, true);
}
else {
showMessageBox("Error : Hauptmenü ist nicht erreichbar", true, true);
}
}
catch (ActivityNotFoundException an) {
showMessageBox("Error :" + an.getMessage(), true, true);
}
catch (Exception e) {
showMessageBox("Error :" + e.getMessage(), true, true);
}
}
protected void showMessageBox(String message, boolean showOKbutton, boolean canceable) {
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(MainActivity.this);
dlgAlert.setMessage(message);
dlgAlert.setTitle("Chronos");
if (showOKbutton) {
dlgAlert.setPositiveButton("OK", null);
}
if (canceable) {
dlgAlert.setCancelable(true);
}
dlgAlert.create().show();
}
}
Here's my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jamesjohnson.chronos"
android:versionCode="1"
android:versionName="1.0.1
" >
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MenuActivity"
android:label="#string/title_activity_menu"
android:parentActivityName=".MainActivity" >
<intent-filter>
<action android:name="com.jamesjohnson.chronos.MenuActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.jamesjohnson.chronos.MainActivity" />
</activity>
</application>
</manifest>
And finally here's the MenuActivity:
package com.jamesjohnson.chronos;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MenuActivity extends ListActivity {
private static final String TAG = "MenuActivity";
static final String[] ENTRIES = new String[] {"Kunden", "Projekte", "Leistungen", "Zeiten"};
ListView listView = getListView();
#Override
protected void onCreate(Bundle savedInstanceState) {
showMessageBox("Activity is beeing created", true, true);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
this.setTitle("Hauptmenü");
this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ENTRIES));
listView.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
showMessageBox("Kunden", true, true);
break;
case 1:
showMessageBox("Projekte", true, true);
break;
case 2:
showMessageBox("Leistungen", true, true);
break;
case 3:
showMessageBox("Zeiten", true, true);
break;
default:
showMessageBox("Error: Undefined index", true, true);
}
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_menu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
protected void showMessageBox(String message, boolean showOKbutton, boolean canceable) {
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(MenuActivity.this);
dlgAlert.setMessage(message);
dlgAlert.setTitle("Chronos");
if (showOKbutton) {
dlgAlert.setPositiveButton("OK", null);
}
if (canceable) {
dlgAlert.setCancelable(true);
}
dlgAlert.create().show();
}
}
Unfortunately I can't show you my Logcat because it doesn't work on my computer. (I always have to export the APK to test the App).
P.S. I am working with Android Studio 1.0.1
...Please HELP ME !
To open a new activity you simply have to call it like this inside the onClick method.
Intent intent = new Intent(v.getContext(), MenuActivity.class);
startActivity(intent);
So your onClick method will look like this.
#Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), MenuActivity.class);
startActivity(intent);
}
Hope this helps.
Is because you say MainActivity.this, but you aren't in the MainActivity context.
You could make a reference of your current context in onCreate() and save it in a field:
private Context context;
#Override
protected void onCreate(Bundle savedInstanceState) {
context = this;
//rest of your code here
}
and use it as:
Intent intent = new Intent(context, MenuActivity.class);
//Something else
context.startActivity(intent);
Go to your manifest file, you will for your MainActivity manifest:
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
Just copy them and paste them for your MenuActivity.
I had the same same problem than you and it worked for me, but I don't know why.
Good luck!
first make sure your AndroidManifest.xml file contain declaration of all Activities in your app, like
<activity android:name=".MenuActivity"/>
then you create new intent and start it where you need to start the second Activity
Intent intent = new Intent(v.getContext(), MenuActivity.class);
startActivity(intent);
This question already has an answer here:
Permission from manifest doesn't work in Android 6
(1 answer)
Closed 7 years ago.
I am trying to build a simple app to send message, but its giving error:
java.langSecurityException:Sending SMS message:uid 10057 does not
have`android.permission.SEND_SMS
even though i have added android.permission.SEND_SMS in manifest, help me solve this problem
main-activity.java
package com.example.manju.helpme;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
import android.widget.Edit
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
/* called when user clicks ALERT! button*/
public final static String EXTRA_MESSAGE = "com.example.HelpMe.Message";
public void sendMessage(){
String phoneNo = "5556";
String message = "hi";
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, message, null, null);
Toast.makeText(getApplicationContext(), "SMS sent",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS failed, please try again.",
Toast.LENGTH_LONG).show();
e.printStackTrace();
Intent intent = new Intent(this,DisplayMessageActivity.class);
String Message = e.toString();
intent.putExtra(EXTRA_MESSAGE, Message);
startActivity(intent);
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnAlert = (Button)findViewById(R.id.btn_Alert);
Button btnAddGuardian = (Button)findViewById(R.id.btn_Add_Guardian);
Button btnRemoveGuardian = (Button)findViewById(R.id.btn_Remove_Guardian);
btnAlert.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
sendMessage();
}
});
btnAddGuardian.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
btnRemoveGuardian.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//no inspection Simplifiable If Statement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Android Manifest.XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.manju.helpme" >
<uses-permission android:name="android.permission.SEND_SMS"> </uses-permission>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Guardians"
android:label="#string/title_activity_guardians"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.manju.helpme.MainActivity" />
</activity>
<activity
android:name=".DisplayMessageActivity"
android:label="#string/title_activity_display_message" >
</activity>
</application>
</manifest>
In my case, I changed the targeted sdk to 19 and also find that you didn't define the uses-sdk in the manifest...!
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
Try changing the uses-permission syntax like this:
<uses-permission android:name="android.permission.SEND_SMS"/>
basically am a java developer but now am developing an android app.In my app i can't redirect to the next page when i click on to SIGN IN button and here is my code
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
public class MainActivity extends ActionBarActivity implements View.OnClickListener {
Button log,sign;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
log = (Button) findViewById(R.id.login);
sign = (Button) findViewById(R.id.signup);
log.setOnClickListener(this);
sign.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()) {
case R.id.login:
break;
case R.id.signup:
Intent open = new Intent("com.example.eblood.Register");
startActivity(open);
break;
}
}
}
}
Here is my next page java code
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Register extends Activity{
Button backlog,regg;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
backlog = (Button) findViewById(R.id.linktologin);
regg = (Button) findViewById(R.id.register);
backlog.setOnClickListener((OnClickListener) this);
}
public void onClick (View v)
{
switch(v.getId()) {
case R.id.register:
break;
case R.id.linktologin:
Intent in = new Intent("com.example.eblood.MainActivity");
startActivity(in);
break;
}
}
}
Here is my manifest code.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.eblood"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.eblood.home"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.eblood.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.eblood.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.eblood.Register"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.REGISTER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
and the error am getting is android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.eblood.Register }
And here is my home.java
package com.example.eblood;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class home extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
Thread timer = new Thread(){
public void run(){
try{
sleep(2000);
} catch (InterruptedException e){
e.printStackTrace();
} finally {
Intent openMainActivity = new Intent("com.example.eblood.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();}{
}
}
Try this..
If you use Intent open = new Intent("com.example.eblood.Register"); you will get ActivityNotFoundException change it as Intent open = new Intent(MainActivity.this,Register.class);
Change this
Intent open = new Intent("com.example.eblood.Register");
startActivity(open);
to
Intent open = new Intent(MainActivity.this,Register.class);
startActivity(open);
also
change this
Intent in = new Intent("com.example.eblood.MainActivity");
startActivity(in);
to
Intent in = new Intent(Register.this,MainActivity.class);
startActivity(in);
EDIT
Change this.
Intent openMainActivity = new Intent("com.example.eblood.MAINACTIVITY");
startActivity(openMainActivity);
to
Intent openMainActivity = new Intent(home.this,MainActivity.class);
startActivity(openMainActivity);
I have implemented a search system in my app, and the search bar appears, but when enter is pressed the search activity doesn't load.
As well as this, the text typed into the search box is black. The action bar is also black, so is there a way to make it white on API 14+?
My MainActivity:
package com.liamwli.spotify.spotifycommunity;
import java.net.MalformedURLException;
import java.net.URL;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.SearchView;
import android.widget.Toast;
#SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
ProgressBar progress;
WebView wv;
WebSettings wvs;
String url, prefix;
SharedPreferences prefs;
SharedPreferences.Editor editor;
ActionBar ab;
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
editor = prefs.edit();
ab = getActionBar();
ab.setHomeButtonEnabled(true);
progress = (ProgressBar) findViewById(R.id.pBProgress);
wv = (WebView) findViewById(R.id.wVPage);
wv.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
if (!url.contains("community.spotify.com")
&& !url.contains("facebook.com")
&& !url.contains("spotify.com")) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
i.addCategory(Intent.CATEGORY_BROWSABLE);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else {
view.loadUrl(url);
}
return super.shouldOverrideUrlLoading(view, url);
}
});
wv.setWebChromeClient(new WebChromeClient() {
#Override
public void onProgressChanged(WebView view, int newProgress) {
// TODO Auto-generated method stub
if (newProgress < 100
&& progress.getVisibility() == ProgressBar.GONE) {
progress.setVisibility(ProgressBar.VISIBLE);
}
progress.setProgress(newProgress);
if (newProgress == 100) {
progress.setVisibility(ProgressBar.GONE);
}
super.onProgressChanged(view, newProgress);
}
});
wvs = wv.getSettings();
if (prefs.getBoolean("javascript_enabled", true)) {
wvs.setJavaScriptEnabled(true);
wvs.setJavaScriptCanOpenWindowsAutomatically(true);
}
if (Build.VERSION.SDK_INT >= 11)
wvs.setDisplayZoomControls(true);
wvs.setSupportZoom(true);
wvs.setSupportMultipleWindows(true);
if (prefs.getBoolean("desktop_mode", false)) {
prefix = "/?device-view=desktop";
} else {
prefix = "/?device-view=mobile";
}
url = "http://community.spotify.com" + prefix;
Intent liam = getIntent();
if (liam.getAction() == Intent.ACTION_VIEW) {
Uri data = liam.getData();
URL urlurl = null;
try {
urlurl = new URL(data.getScheme(), data.getHost(),
data.getPath());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException("Malformed URL Given");
}
url = urlurl.toString() + prefix;
}
if (url == null)
throw new RuntimeException("URL Null");
wv.loadUrl(url);
}
#SuppressLint("NewApi")
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.activity_main, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search)
.getActionView();
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the
// widget;
// expand it by default
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.menu_back:
if (wv.canGoBack()) {
wv.goBack();
} else {
Toast.makeText(this, "Can't Go Back!", Toast.LENGTH_SHORT)
.show();
}
break;
case R.id.menu_forward:
if (wv.canGoForward()) {
wv.goForward();
} else {
Toast.makeText(this, "Can't Go Forward!", Toast.LENGTH_SHORT)
.show();
}
break;
case R.id.menu_refresh:
wv.reload();
break;
case R.id.menu_settings:
Intent i = new Intent(this, PrefActivity.class);
startActivity(i);
break;
case R.id.menu_search:
onSearchRequested();
break;
case android.R.id.home:
wv.loadUrl("http://community.spotify.com" + prefix);
break;
}
return super.onOptionsItemSelected(item);
}
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.liamwli.spotify.spotifycommunity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.liamwli.spotify.spotifycommunity.StartActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.liamwli.spotify.spotifycommunity.MainActivity"
android:excludeFromRecents="true"
android:exported="true"
android:label="#string/app_name"
tools:ignore="ExportedActivity" >
<intent-filter>
<action android:name="com.liamwli.spotify.spotifycommunity.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
<activity
android:name="com.liamwli.spotify.spotifycommunity.PostUrl"
android:excludeFromRecents="true"
android:exported="false"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.liamwli.spotify.spotifycommunity.POSTURL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.liamwli.spotify.spotifycommunity.PrefActivity"
android:exported="false"
android:label="#string/app_name" >
<intent-filer>
<action android:name="com.liamwli.spotify.spotifycommunity.PREFACTIVITY" />
<category android:name="android.intent.cetagory.PREFERENCE" />
</intent-filer>
</activity>
<activity
android:name="com.liamwli.spotify.spotifycommunity.ClearData"
android:excludeFromRecents="true"
android:exported="false"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.liamwli.spotify.spotifycommunity.CLEARDATA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.liamwli.spotify.spotifycommunity.SearchActivity"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<provider
android:name="com.liamwli.spotify.spotifycommunity.MySuggestionProvider"
android:authorities="com.liamwli.spotify.spotifycommunity.MySuggestionProvider"
android:exported="true" />
</application>
</manifest>
My SearchActivity:
package com.liamwli.spotify.spotifycommunity;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.SearchRecentSuggestions;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.Toast;
public class SearchActivity extends Activity {
WebView wv;
SharedPreferences prefs;
SharedPreferences.Editor editor;
String prefix;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
editor = prefs.edit();
wv = (WebView) findViewById(R.id.wVPage);
if (prefs.getBoolean("desktop_site", false)) {
prefix = "/?device-view=desktop";
} else {
prefix = "/?device-view=mobile";
}
// Get the intent, verify the action and get the query
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
this, MySuggestionProvider.AUTHORITY,
MySuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
doMySearch(query);
}
}
private void doMySearch(String query) {
// TODO Auto-generated method stub
wv.loadUrl("http://community.spotify.com/t5/forums/searchpage/tab/message?q="
+ query + prefix);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.activity_main_nosearch, menu);
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.menu_back:
if (wv.canGoBack()) {
wv.goBack();
} else {
Toast.makeText(this, "Can't Go Back!", Toast.LENGTH_SHORT)
.show();
}
break;
case R.id.menu_forward:
if (wv.canGoForward()) {
wv.goForward();
} else {
Toast.makeText(this, "Can't Go Forward!", Toast.LENGTH_SHORT)
.show();
}
break;
case R.id.menu_refresh:
wv.reload();
break;
case R.id.menu_settings:
Intent i = new Intent(this, PrefActivity.class);
startActivity(i);
break;
case android.R.id.home:
wv.loadUrl("http://community.spotify.com" + prefix);
break;
}
return super.onOptionsItemSelected(item);
}
}
I don't receive a force close - it just doesn't launch the search activity.
Also, what permission should I set for the final provider? The android system must be able to execute it,