Following my previous question about messaging on javafx,
I want to notify user when message arrive.
Recently I use NotificationCompat.
When user touch the notification from notification bar, it must directly open related view (DirectMessageView).
I’ve configure an activity class (NotificationActivy extends Activity) on receive tag in androidmanifest.xml and call DirectMessageView and it's presenter on method "onCreate".
when user touch message on notification, it won’t display DirectMessageView, but the method inside presenter is called, and the view is not visible. Perhaps it’s my wrong implementation, please help
Here are classes I have created
Class SKSAplication that extends MobileAplication
public class SKSApplication extends MobileApplication{
private static SKSApplication instance;
public static final String DIRECT_MESSAGE_VIEW = "DIRECT_MESSAGE_VIEW";
public static final String GROUP_MESSAGE_VIEW = "GROUP_MESSAGE_VIEW";
private ViewRefresh activeView;
public SKSApplication() {
instance = this;
}
public static SKSApplication getInstance() {
return instance;
}
#Override
public void init() {
addViewFactory(HOME_VIEW, () -> {
HomeView homeView = new HomeView();
homePresenter = (HomePresenter) homeView.getPresenter();
return (View) homeView.getView();
});
addViewFactory(DIRECT_MESSAGE_VIEW, () -> {
DirectMessageView directMessageView = new DirectMessageView();
return (View) directMessageView.getView();
});
addViewFactory(GROUP_MESSAGE_VIEW, () -> {
GroupMessageView groupMessageView = new GroupMessageView();
return (View) groupMessageView.getView();
});
public void doRefreshMessageUI(Object objectModel) {
System.out.println("SKSApplication.doRefreshMessageUI " + getView().getName());
if (getActiveView() != null)
getActiveView().doRefresh(objectModel);
}
public ViewRefresh getActiveView() {
return activeView;
}
public void setActiveView(ViewRefresh activeView) {
this.activeView = activeView;
}
}
Class MyGCMListenerService
public class MyGCMListenerService extends GcmListenerService {
private final String NOTIFICATION_TAG = "NotificationExample";
public MyGCMListenerService() {
}
#Override
public void onMessageReceived(String from, Bundle data) {
String varMessage = data.getString("message");
try {
JSONObject json = new JSONObject(varMessage);
String messageContent = getStringFromJSON(json, "message");
Integer senderId = getIntegerFromJSON(json, "senderId");
String senderName = getStringFromJSON(json, "senderName");
String comId = getStringFromJSON(json, "communityId");
String salesGroup = getStringFromJSON(json, "salesGroup");
Integer messageType = getIntegerFromJSON(json, "type");
doViewNotification(messageType, senderName, salesGroup);
SKSApplication.getInstance().doRefreshMessageUI(messageContent,senderId,senderName,comId );
} catch (JSONException e) {
e.printStackTrace();
}
}
private void doViewNotification(Integer messageType, String senderName, String salesGroup) {
StringBuilder msg = new StringBuilder()
.append("Message from ")
.append(senderName)
.append(" #").append(salesGroup);
Intent resultIntent = new Intent(FXActivity.getInstance(), NotificationActivity.class);
resultIntent.putExtra(Constants.EXTRA_INTENT.MESSAGE_TYPE.getValue(), messageType);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
FXActivity.getInstance(),
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
long[] v = {500, 1000};
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSound(uri)
.setSmallIcon(FXActivity.getInstance().getApplicationInfo().icon)
.setContentTitle(getApplicationName(FXActivity.getInstance().getApplicationContext()))
.setVibrate(v)
.setContentText(msg.toString())
.setPriority(Notification.PRIORITY_DEFAULT)
.setNumber(100)
.setWhen(System.currentTimeMillis())
.setContentIntent(resultPendingIntent)
.setAutoCancel(true)
.addAction(FXActivity.getInstance().getApplicationInfo().icon, "Action", null);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
notificationManager.notify(NOTIFICATION_TAG, 0, builder.build());
} else {
notificationManager.notify(NOTIFICATION_TAG.hashCode(), builder.build());
}
}
}
layout xml file (directmessage.fxml)
<View xmlns:fx="http://javafx.com/fxml/1" fx:id="directMessageView" prefHeight="600.0" prefWidth="400.0"
xmlns="http://javafx.com/javafx/8.0.40"
fx:controller="com.tenma.mobile.message.directmessage.DirectMessagePresenter">
</View>
Class DirectMessageView
public class DirectMessageView extends FXMLView {
}
Class DirectMessagePresenter
public class DirectMessagePresenter implements Initializable, ViewRefresh{
#Override
public void initialize(URL location, ResourceBundle resources) {
{
directMessageView.showingProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
SKSApplication.getInstance().setActiveView(this);
doViewMessage();
}
});
}
private void doViewMessage() {
listMessage.getItems().clear();
MessageStoryHelper hlp = new MessageStoryHelper();
List<MessageModel> ls = null;
try {
ls = hlp.getMessages(Constants.MESSAGE_TYPE.DIRECT);
if (ls != null && ls.size() != 0)
for (MessageModel m :ls)
listMessage.add(m);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
androidmanifest
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tenma.mobile"
android:versionCode="1" android:versionName="1.0">
<supports-screens android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<permission android:name="com.tenma.mobile.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.tenma.mobile.permission.C2D_MESSAGE"/>
<application android:label="MobileSales" android:name="android.support.multidex.MultiDexApplication"
android:icon="#mipmap/ic_launcher">
<activity android:name="javafxports.android.FXActivity" android:label="MobileSales"
android:configChanges="orientation|screenSize">
<meta-data android:name="main.class" android:value="com.tenma.mobile.SKSApplication"/>
<meta-data android:name="debug.port" android:value="0"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.tenma.mobile.common.NotificationActivity"
android:parentActivityName="javafxports.android.FXActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="javafxports.android.FXActivity"/>
</activity>
<!--start-->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<!-- for Gingerbread GSF backward compat -->
<!--<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>-->
<category android:name="com.tenma.mobile"/>
</intent-filter>
</receiver>
<!--end-->
<service
android:name="com.tenma.mobile.common.MyGCMListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
</application>
</manifest>
Class NotificationActivity extends Activity
public class NotificationActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent launchIntent = getIntent();
it working, but no view is visible
SKSApplication.getInstance().switchView(SKSApplication.DIRECT_MESSAGE_VIEW);
perhaps using this line below, but how to set Gluon View setContentView?
or retreive view ID and setContentView?
DirectMessageView directMessageView = new DirectMessageView();
Parent v = directMessageView.getView();
FXActivity.getInstance().setContentView(?????????);
}
}
Any help would be appreciated
Thank you in advance
Assuming you have the application running, this works for me:
Once you send the message back to the View, you need to close the notification activity by calling finish():
public class NotificationActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((SKSApplication) MobileApplication.getInstance()).doRefreshMessageUI("Hi from NotificationActivity");
finish();
}
}
Note you don't need to create a singleton instance of SKSApplication, you can retrieve an instance of it at any time by calling MobileApplication.getInstance().
Passing the message to the view can be done in SKSApplication by using Platform.runLater(), since you are not running on the JavaFX thread.
And to retrieve the corresponding view, just switch to that view:
public void doRefreshMessageUI(String msg) {
Platform.runLater(() -> {
messagesView.messageProperty().set(msg);
switchView(DIRECT_MESSAGE_VIEW);
});
}
providing the view has a StringProperty, that is bound to any of its controls text property.
private StringProperty message = new SimpleStringProperty();
public StringProperty messageProperty() {
return message;
}
Related
I want to make a theme app and I have a home page where I am trying to show some theme As a category, and there I am using RecyclerView for each category, and my Recyclerview get data from firebase real-time database where I use one image link, one text, and one URL which I want to show in my WebView through this code
Intent intent = new Intent(v.getContext().getApplicationContext(), BrowserActivity.class);
intent.putExtra("url_E", url);
v.getContext().startActivity(intent);
but the problem is all items are fetching perfectly from firebase, and showing the correct title and image each and every item of my Recyclerview but if I click the 6 or 7 items from Recyclerview then the link was not loaded correctly, The link that is loading is not that item link, The link is being replaced with another item link and that wrong link I can find in the database from another item in the same category.
****Please Help Me
If I add a Toast.makeText(, url, Toast.LENGTH_SHORT).show(); with setOnClickListener then the correct link is showing in Toast but the load link on the webpage is wrong same!!!! -- -- 🤦♀️🤦♂️🤦♂️🤦♂️🤦♂️
HErer is my activity :
enter image description here
layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal">
<ImageView
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_gravity="bottom"
android:layout_marginStart="5dp"
android:layout_marginEnd="10sp"
android:src="#drawable/theme_review" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/RVModern"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="8dp"
android:paddingStart="10dp" />
MainFragemnt:
DataRef = FirebaseDatabase.getInstance().getReference("ThemeByStyle");
// Modern
DataRef.child("ModernTheme").addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot npsnapshot : dataSnapshot.getChildren()) {
ListDataMODERN = npsnapshot.getValue(ListData.class);
listData1.add(ListDataMODERN);
}
homeAdapter = new HomeAdapter(listData1);
RVModern.setAdapter(homeAdapter);
Collections.reverse(listData1);
RVModern.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
homeAdapter.notifyDataSetChanged();
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
adapter:
{
private final List<ListData> listData;
CardView ClickItem;
String url;
ImageView post_img;
TextView post_title;
Dialog OkBox;
public HomeAdapter (List<ListData> listData) {
this.listData = listData;
}
#SuppressLint("WrongConstant")
#NonNull
#Override
public HomeAdapter.ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_body_home,parent,false);
ClickItem = view.findViewById(R.id.cardview);
OkBox = new Dialog(view.getContext());
return new HomeAdapter.ViewHolder(view);
}/**************************************************************************/
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
final ListData listdata = listData.get(position);
holder.setUrlss(listdata.getUrls());
holder.setTitle(listdata.getTitle());
holder.setImgOne(listdata.getImg1());
// url = listdata.getUrls();
}
#Override
public int getItemCount () {
return listData.size();
// return 2;
}
public class ViewHolder extends RecyclerView.ViewHolder {
View vv;
public ViewHolder(View itemView) {
super(itemView);
vv = itemView;
}
public void setTitle(String title) {
post_title = vv.findViewById(R.id.post_title);
post_title.setText(title);
}
public void setImgOne(String imgone) {
post_img = vv.findViewById(R.id.imgOne);
Glide
.with(vv)
.load(imgone)
.into(post_img);
}
public void setUrlss (String setUrls) {
TextView urltxt = vv.findViewById(R.id.urltxt);
urltxt.setText(setUrls);
url = setUrls;
ClickItem.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext().getApplicationContext(), BrowserActivity.class);
intent.putExtra("url_E", url);
v.getContext().startActivity(intent);
/* Okbox();
ClipboardManager clipboard = (ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", setUrlXX);
clipboard.setPrimaryClip(clip);
Toast.makeText(v.getContext().getApplicationContext(), setUrlXX, Toast.LENGTH_SHORT).show();*/
}
});
}
}
private void Okbox() {
OkBox.setContentView(R.layout.ok);
Window window = OkBox.getWindow();
window.setLayout(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.TOP);
TextView t0title = OkBox.findViewById(R.id.t0title);
t0title.setText(url);
OkBox.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
OkBox.show();
}
}
HELP ME PLZ PLZ PLZ PLZ PLZ PLZ PLZ PLZ
I've tried my code in normal activity both images and text show. in fragment only image showing but the text is not showing (in both normal and fragment activity I've used same xml layout). I'm using firebaselistadpter for gridview and it works fine. I also tried using it with listview in fragment still images only showing but no text showing. (there is no Error message).
1- my java activity:
public class R_MainCat extends Fragment {
private GridView gridView;
private DatabaseReference myRef;
private FirebaseListAdapter<Sub_Category_Data> adapter;
private TextView mc_name;
private ImageView url;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_gridview, container, false);
rootView.setBackgroundColor(Color.WHITE);
myRef= FirebaseDatabase.getInstance().getReference("Main_Category");
Firebase.getDefaultConfig().setPersistenceEnabled(true);
gridView = (GridView) rootView.findViewById(R.id.gridview);
FirebaseListOptions<Sub_Category_Data> options = new FirebaseListOptions.Builder<Sub_Category_Data>()
.setQuery(myRef, Sub_Category_Data.class).setLayout(R.layout.gridview_icon).build();
adapter = new FirebaseListAdapter<Sub_Category_Data>(options) {
#Override
protected void populateView(View v, Sub_Category_Data model, int position) {
mc_name = v.findViewById(R.id.cat_name);
url = v.findViewById(R.id.img);
mc_name.setText(model.getName());
Picasso.with(getActivity()).load(model.getUrl()).into(url);
}
};
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
switch(i)
{
case 0:
R_DairyProds f1 = new R_DairyProds();
FragmentTransaction fragTransaction1 = getFragmentManager().beginTransaction();
fragTransaction1.replace(R.id.container_view,f1 );
fragTransaction1.addToBackStack(null);
fragTransaction1.commit();
break;
case 1:
R_Bakery f2 = new R_Bakery();
FragmentTransaction fragTransaction2 = getFragmentManager().beginTransaction();
fragTransaction2.replace(R.id.container_view,f2 );
fragTransaction2.addToBackStack(null);
fragTransaction2.commit();
break;
case 2:
R_Grocery f3 = new R_Grocery();
FragmentTransaction fT3 = getFragmentManager().beginTransaction();
fT3.replace(R.id.container_view,f3);
fT3.addToBackStack(null);
fT3.commit();
break;
case 3:
R_FruitsNVegs f4 = new R_FruitsNVegs();
FragmentTransaction fT4 = getFragmentManager().beginTransaction();
fT4.replace(R.id.container_view,f4);
fT4.addToBackStack(null);
fT4.commit();
break;
case 4:
R_CleanNWash f5 = new R_CleanNWash();
FragmentTransaction fT5 = getFragmentManager().beginTransaction();
fT5.replace(R.id.container_view,f5);
fT5.addToBackStack(null);
fT5.commit();
break;
}
}
});
return rootView;
}
#Override
public void onStart() {
super.onStart();
adapter.startListening();
}
#Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
}
2-my xml layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:descendantFocusability="blocksDescendants"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<me.grantland.widget.AutofitLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/img"
>
<TextView
android:id="#+id/cat_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hello_world"
android:textColor="#000"
android:textSize="20sp"
android:gravity="center"
/>
</me.grantland.widget.AutofitLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
3- my Data model java:
public class Sub_Category_Data {
private String mc_name;
private String url;
public Sub_Category_Data() {
}
public void setName(String mc_name) {
this.mc_name = mc_name;
}
public String getName() {
return mc_name;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrl() {
return url;
}
}
4- snapshot of the output:
text suppose to be showing under the image.
Output in fragment
I want my fragment to show the text data same as what is showing in this image
Output I've tested in normal Activity
5- database snapshot:
Database Image
does anyone have any clue? or have faced this issue before? because I'm lost since there is no error showing besides the fact it works fine in normal activity but text is not showing in the fragment. thank you in advance.
after looking over and over I noticed this in logcat
"No setter/field for mc_name found on class"
I've fixed the problem. It was in the model class getName() and SetName() methods I changed them to same name as the child key name in my firebase you can see picture of the database in the question above. so the new methods are getMc_name() and setMc_name().
public class Sub_Category_Data {
private String mc_name;
private String url;
public Sub_Category_Data() {
}
public String getMc_name() {
return mc_name;
}
public void setMc_name(String mc_name) {
this.mc_name = mc_name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
the output screen shot
I've started dealing with Fragments in Android. I created Activity with NavigationView which has 3 items and worked with 3 simple fragments till now. NavigationHeader has 2 buttons - 1 starts LoginActivity and 2nd RegisterActivity. I remind that everything till niw worked fine. Today I've tried to create RecyclerView inside one of the fragments. Now when I try to run app, findViewById applied to those 2 NavigationHeader buttons returns NULL. I have no idea why.
Here is HomeActivity:
public class HomeActivity extends AppCompatActivity {
private static final String FRAGMENT_POSITION = "fragment_position"; // Fragment Position
private DrawerLayout mDrawerLayout; // NavigationDrawer Layout
private NavigationView nvDrawer; // NavigationView
private CoordinatorLayout homeCoordinatorLayout; // Coordinator Layout For Snackbar
private Toolbar toolbar; // Application Toolbar
private TextView navHeaderNamePlusSurname; // Name And Surname Navigation Header Text
private TextView navHeaderEmail; // E-mail Navigation Header Text
AppCompatButton navHeaderButtonLogin; // Login/Logout Button
AppCompatButton navHeaderButtonRegister; // Register Button
private ActionBarDrawerToggle mDrawerToggle; // ActionBar Drawer Toggle
private SQLiteHandler db; // SQLite Database Helper Class
private SessionManager session; // Session Manager
private int lastShownFragment;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
// Setting Toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
// Setting Up DrawerLayout
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = setupDrawerToggle();
mDrawerLayout.setDrawerListener(mDrawerToggle);
// Navigation Header Logout Button
navHeaderButtonLogin = (AppCompatButton) findViewById(R.id.nav_header_btn_log_in_out);
navHeaderButtonRegister = (AppCompatButton) findViewById(R.id.nav_header_btn_register);
Log.d("czy_null", "navHeaderButtonLogin: " + navHeaderButtonLogin + ", navHeaderButtonRegister: " + navHeaderButtonRegister);
// Name, Surname And E-mail Texts
navHeaderNamePlusSurname = (TextView) findViewById(R.id.nav_header_name_plus_surname);
navHeaderEmail = (TextView) findViewById(R.id.nav_header_email);
// SQLite Database Handler
db = new SQLiteHandler(getApplicationContext());
// Session Manager
session = new SessionManager(getApplicationContext());
// Navigation Drawer
nvDrawer = (NavigationView) findViewById(R.id.navigation_view);
// Checking If User Is Logged In
if (!session.isLoggedIn()) {
hideNavigationViewGroup(nvDrawer); // Hiding NavigationView Group Depending
// If Not Logged
} else {
navHeaderButtonLogin.setText(getText(R.string.home_btn_log_out));
navHeaderButtonRegister.setVisibility(View.INVISIBLE);
// Fetching User Details From SQLite
HashMap<String, String> user = db.getUserDetails();
String name = user.get(SQLiteHandler.KEY_NAME);
String surname = user.get(SQLiteHandler.KEY_SURNAME);
String email = user.get(SQLiteHandler.KEY_EMAIL);
// Setting Navigation Header Texts
String nameSurname = name + " " + surname;
navHeaderNamePlusSurname.setText(nameSurname);
navHeaderEmail.setText(email);
}
// Setting Up CoordinatorLayout
homeCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.home_coordinator_layout);
// Setting Listener To NavigationView
setupDrawerContent(nvDrawer);
// Setting Starting Fragment
if (savedInstanceState == null) {
setStartingFragment();
} else {
restoreOnInstanceState(savedInstanceState.getInt(FRAGMENT_POSITION));
}
// Applying Login/Logout Button Listener
setLoginButtonListener();
// Applying Register Button Listener
setRegisterButtonListener();
}
// Listener To Login/Register Button
private void setLoginButtonListener() {
navHeaderButtonLogin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (!session.isLoggedIn()) {
mDrawerLayout.closeDrawers();
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
} else {
mDrawerLayout.closeDrawers();
logoutUser();
navHeaderNamePlusSurname.setText(getString(R.string.nav_header_name_surname));
navHeaderEmail.setText(getString(R.string.nav_header_email));
hideNavigationViewGroup(nvDrawer);
navHeaderButtonLogin.setText(getString(R.string.home_btn_log_in));
navHeaderButtonRegister.setVisibility(View.VISIBLE);
showSnackbarInfo(getString(R.string.inf_logout_success),
R.color.snackbar_success_msg);
}
}
});
}
// Listener To Register Button
private void setRegisterButtonListener() {
navHeaderButtonRegister.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent intent = new Intent(getApplicationContext(), SignUpActivity.class);
startActivity(intent);
}
});
}
// Logging Out The User
private void logoutUser() {
session.setLogin(false);
db.deleteUsers();
}
// Setting Up DrawerToggle
private ActionBarDrawerToggle setupDrawerToggle() {
return new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open,
R.string.drawer_close);
}
// Setting Up Drawer Content
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
selectDrawerItem(menuItem);
return true;
}
});
}
// Replace Existing Fragment With a New One
public void selectDrawerItem(MenuItem menuItem) {
Fragment fragment = null;
Class fragmentClass = null;
switch(menuItem.getItemId()) {
case R.id.nav_top20_recipes: {
fragmentClass = Top20RecipesFragment.class;
lastShownFragment = 0;
break;
}
case R.id.nav_kitchen_type: {
fragmentClass = KitchenTypeFragment.class;
lastShownFragment = 1;
break;
}
case R.id.nav_meal_type: {
fragmentClass = MealTypeFragment.class;
lastShownFragment = 2;
break;
}
}
try {
fragment = (Fragment) fragmentClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frame_layout_content, fragment);
fragmentTransaction.commit();
menuItem.setChecked(true); // Highlight The Selected Item
setTitle(menuItem.getTitle()); // Updating Toolbar Title
mDrawerLayout.closeDrawers(); // Close The Drawer
}
// Function Setting First Fragment
private void setStartingFragment() {
Fragment fragment = null;
Class fragmentClass = Top20RecipesFragment.class;
try {
fragment = (Fragment) fragmentClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frame_layout_content, fragment);
fragmentTransaction.commit();
lastShownFragment = 0;
MenuItem menuItem = nvDrawer.getMenu().getItem(0);
menuItem.setChecked(true); // Highlight The Selected Item
setTitle(menuItem.getTitle()); // Updating Toolbar Title
}
// Saving Fragment Title State
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(FRAGMENT_POSITION, lastShownFragment);
}
// Restoring Fragment Title States
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
restoreOnInstanceState(savedInstanceState.getInt(FRAGMENT_POSITION));
}
// Restoring Selected Item On Screen Rotation Or App Minimalize
private void restoreOnInstanceState(int lastPosition) {
Fragment fragment = null;
Class fragmentClass = null;
switch (lastShownFragment) {
case 0: {
fragmentClass = Top20RecipesFragment.class;
break;
}
case 1: {
fragmentClass = KitchenTypeFragment.class;
break;
}
case 2: {
fragmentClass = MealTypeFragment.class;
break;
}
}
try {
fragment = (Fragment) fragmentClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frame_layout_content, fragment);
fragmentTransaction.commit();
lastShownFragment = lastPosition;
MenuItem menuItem = nvDrawer.getMenu().getItem(lastPosition);
menuItem.setChecked(true); // Highlight The Selected Item
setTitle(menuItem.getTitle());
}
#Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
// Function Hiding Items In NavigationView
private void hideNavigationViewGroup(NavigationView nvDrawer) {
nvDrawer.getMenu().setGroupVisible(R.id.nav_group_logged_user, false);
}
// Function Showing Snakcbar
private void showSnackbarInfo(String info, int textColor) {
Snackbar snackbar = Snackbar.make(homeCoordinatorLayout, info, Snackbar.LENGTH_LONG);
View sbView = snackbar.getView();
TextView sbText = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
sbText.setTextColor(ContextCompat.getColor(getApplicationContext(), textColor));
snackbar.show();
}
}
Here is my fragment which has to contain RacyclerView:
public class KitchenTypeFragment extends Fragment {
RecyclerView kitchenTypeRecycleView;
private ArrayList<KitchenTypeItem> kitchenTypeItems;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
kitchenTypeItems = new ArrayList<>();
fillKitchenTypeArray(kitchenTypeItems);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_kitchen_type, container, false);
return rootView;
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
kitchenTypeRecycleView = (RecyclerView) view.findViewById(R.id.kitchen_type_recycle_view);
kitchenTypeRecycleView.setHasFixedSize(true);
kitchenTypeRecycleView.setAdapter(new KitchenTypeAdapter(kitchenTypeItems,
R.layout.kitchen_type_grid_item));
kitchenTypeRecycleView.setLayoutManager(new GridLayoutManager(getContext(), 2));
kitchenTypeRecycleView.setItemAnimator(new DefaultItemAnimator());
}
private void fillKitchenTypeArray( ArrayList<KitchenTypeItem> kitchenTypeItems) {
KitchenTypeItem kitchenItem;
// Currently 8 Kitchen Types
String[] itemNames = getResources().getStringArray(R.array.kitchen_types);
// Filling ArrayList
for(int i = 0; i < itemNames.length; i++) {
kitchenItem = new KitchenTypeItem(itemNames[i], R.drawable.example_kitchen_type);
kitchenTypeItems.add(kitchenItem);
}
}
}
Here is XML from HomeActivity:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/home_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RegisterActivity">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".SignUpActivity">
<!-- This LinearLayout represents the contents of the screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The ActionBar displayed at the top -->
<include
android:id="#+id/toolbar"
layout="#layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- The main content view where fragments are loaded -->
<FrameLayout
android:id="#+id/frame_layout_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- The navigation drawer that comes from the left -->
<!-- Note that `android:layout_gravity` needs to be set to 'start' -->
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/drawer_view"
app:headerLayout="#layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
Here is NavigationHeader XML with those 2 buttons:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/relative_nav_header"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="192dp"
android:background="#color/primary"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:paddingTop="40dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical">
<!-- Name + Surname, E-mail -->
<LinearLayout
android:id="#+id/nav_lin_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:orientation="vertical">
<!-- Name + Surname Text -->
<TextView
android:id="#+id/nav_header_name_plus_surname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:textSize="17sp"
android:text="#string/nav_header_name_surname" />
<!-- E-mail Adress -->
<TextView
android:id="#+id/nav_header_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/accent"
android:fontFamily="sans-serif"
android:textSize="13sp"
android:text="#string/nav_header_email" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="7dp"
android:gravity="center|left"
android:layout_below="#+id/nav_lin_layout">
<!-- Login/Logut Button -->
<android.support.v7.widget.AppCompatButton
android:id="#+id/nav_header_btn_log_in_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:backgroundTint="#color/nav_header_login_color"
android:textColor="#color/text_icons"
android:stateListAnimator="#null"
android:text="#string/btn_log_in" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/nav_header_btn_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:backgroundTint="#color/nav_header_register_color"
android:stateListAnimator="#null"
android:textColor="#color/text_icons"
android:text="#string/btn_sign_up" />
</LinearLayout>
</RelativeLayout>
And here is finally XML from Fragment:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/kitchen_type_fragment"
android:padding="16dp"
tools:context="com.example.nazwamarki.myapplication.fragments.KitchenTypeFragment">
<android.support.v7.widget.RecyclerView
android:id="#+id/kitchen_type_recycle_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
You should use findViewById on the headerView like this:
navigationView.getHeaderView(0).findViewById()
The activity is called from another activity delivering a string array, which needs to be displayed in a fragment of the target activity.
MainActivity (string array) -> Result2Activity: Tab1 should display string index0, Tab2 should display string index1 etc.
I followed a similar problem here:
Access Fragment View from Activity's onCreate
My problem is right now that the onActivityCreated method is never called in the Result2Activity.
I am also not sure if this method is the right way to address the fragment:
getSupportFragmentManager().findFragmentByTag("Out1");
What is the best way to achieve that ?
Result2Activity:
public class Result2Activity extends ActionBarActivity implements
ActionBar.TabListener {
/**
* The {#link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a {#link FragmentPagerAdapter}
* derivative, which will keep every loaded fragment in memory. If this
* becomes too memory intensive, it may be best to switch to a
* {#link android.support.v4.app.FragmentStatePagerAdapter}.
*/
SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {#link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
public List<String> fragments = new Vector<String>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.result2_activity);
// Set up the action bar.
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager
.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
#Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
Log.d("DEBUG","1: onCreate finished");
}
public void onActivityCreated (Bundle savedInstanceState) {
Log.d("DEBUG","2: onActivityCreated finished");
//super.onActivityCreated(savedInstanceState);
// retrieve data from MainActivity
Intent intent = getIntent();
String message[] = intent.getStringArrayExtra(MainActivity.OUTPUT);
//send data to fragment Out1Fragment
Out1Fragment set_out1 =
(Out1Fragment)
getSupportFragmentManager().findFragmentByTag("Out1");
set_out1.settext(message[0]);
}
#Override
public void onTabSelected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
#Override
public void onTabUnselected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
}
#Override
public void onTabReselected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
fragments.add(Out1Fragment.class.getName());
fragments.add(Out2Fragment.class.getName());
fragments.add(Out3Fragment.class.getName());
}
#Override
public Fragment getItem(int position) {
Fragment fragment = null;
switch (position) {
case 0:
fragment = new Out1Fragment();
break;
case 1:
fragment = new Out2Fragment();
break;
case 2:
fragment = new Out3Fragment();
break;
}
return fragment;
}
#Override
public int getCount() {
// Show 3 total pages.
return 3;
}
#Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.out_section1).toUpperCase(l);
case 1:
return getString(R.string.out_section2).toUpperCase(l);
case 2:
return getString(R.string.out_section3).toUpperCase(l);
}
return null;
}
}
}
Out1Fragment:
public class Out1Fragment extends Fragment {
private static TextView textview;
public Out1Fragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View dataView = inflater.inflate(R.layout.out1_fragment, container,
false);
textview = (TextView) dataView.findViewById(R.id.outPut1);
return dataView;
}
public void settext(String text)
{
textview.setText(text);
}
}
XML Resource:
result2_activity.xml
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="dd.testing.finance.Result2Activity" />
out1_fragment.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ScrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:tag="Out1"
tools:context="dd.testing.finance.Result2Activity$Out1Fragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/outPut1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10sp"
android:layout_marginRight="10sp"
android:textSize="16sp" />
</LinearLayout>
</ScrollView>
Not really sure if this was the right way, but at least it does exaclty what I needed.
In the Out1Fragment.class added the onActivityCreated method:
public void onActivityCreated (Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
settext(((Result2Activity)getActivity()).getOutput1());
}
From there calling the added method getOutput1 in the Result2Activity:
public String getOutput1 () {
// retrieve data from MainActivity
Intent intent = getIntent();
String message[] = intent.getStringArrayExtra(MainActivity.OUTPUT);
return message[0];
}
I searched for a solution for more than a week to my situation and I have not found the solution.
I have a main activity and use Fragments. In my project I added a SPLASH, but as soon as it finishes executing the program opens twice.
Here's the code:
MainActivity.java
package org.jotadev.nh;
import org.jotadev.nh.adapter.TabsPagerAdapter;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "Buscar", "Historial", "Favoritos", "Planes" };
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);//activity_main
Log.i("MainActivity", "entró en onCreate");
// Initialization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
}
/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
actionBar.setSelectedNavigationItem(position);
Log.i("MainActivity", "entró en onPageSelected");
}
#Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
#Override
public void onPageScrollStateChanged(int arg0) {
}
});
});
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
//menu
#Override
public boolean onCreateOptionsMenu(Menu menu){
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
public void lanzarAbout(){
Intent intent = new Intent(this, About.class);
startActivity(intent);
}
#Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()){
case R.id.action_about:
lanzarAbout();
break;
case R.id.action_settings:
Intent intent = new Intent(this, Preferences.class);
startActivity(intent);
break;
case R.id.action_show_preferences:
Log.i("Action", "mostrando ajustes");
mostrarPreferencias();
break;
case R.id.action_exit:
finish();
}
return false;
}
private void mostrarPreferencias() {
SharedPreferences pref = getSharedPreferences("org.jotadev.nh_preferences",MODE_PRIVATE);
String s = "pantalla completa: " + pref.getBoolean("PantallaCompleta", false)
+ ", tamaño letra: " + pref.getString("Tamanoletra", "?")
+ ", color Fondo: " + pref.getString("ColorFondo", "?")
+ "En Desarrollo: " + pref.getBoolean("Endesarrollo", true);
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
}
}
activity_main.xml
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
AndroidManifiest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jotadev.nh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<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"
android:debuggable="true"
>
<!-- Splash -->
<activity
android:name=".Splash"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="org.jotadev.nh.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:label="#string/app_name"
android:name=".About">
</activity>
<activity android:label="#string/title_settings"
android:name=".Preferences">
</activity>
</application>
</manifest>
I appreciate your help. Or please share an useful link. It is very dificult to find answers.