Skip to content

Instantly share code, notes, and snippets.

// Persistence in the Service
Gson gson = new Gson();
Type type = new TypeToken<List<RssItem>>() {}.getType();
String json = gson.toJson(list, type);
try (FileOutputStream openFileOutput =
openFileOutput(RssApplication.RSS_FILE, Context.MODE_PRIVATE);) {
openFileOutput.write(json.getBytes());
} catch (Exception ex){
// do nothing
package com.example.android.rssreader;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Intent;
import com.example.android.rssfeedlibrary.RssFeedProvider;
import com.example.android.rssfeedlibrary.RssItem;
package com.example.android.rssreader;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.widget.FrameLayout;
public class RssfeedActivity extends Activity implements
MyListFragment.OnItemSelectedListener {
package com.example.e4.rcp.todo.addons;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.EventTopic;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class Main {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
package com.vogella.android.multitouch;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.MotionEvent;
BroadcastReceiver updateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateListContent();
}
};
IntentFilter f = new IntentFilter("ESGIBTNEUEDATEN");
List<RssItem> list = RssFeedProvider.parse(url);
RssApplication.list.clear();
RssApplication.list.addAll(list);
Gson gson = new Gson();
Type type = new TypeToken<List<RssItem>>() {}.getType();
String json = gson.toJson(list, type);
try (FileOutputStream openFileOutput = getActivity().openFileOutput(RssApplication.RSS_FILE, Context.MODE_PRIVATE);)
{
openFileOutput.write(json.getBytes());
} catch (Exception ex){
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
tb.inflateMenu(R.menu.mainmenu);
tb.setOnMenuItemClickListener(
new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return onOptionsItemSelected(item);
}
package com.example.android.rssreader;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
public class RssfeedActivity extends Activity implements
MyListFragment.OnItemSelectedListener {