How to create non renewable subscription in Google play console - in-app-purchase

Currently, I have auto renewable subscription setup. But i want to create non renewable subscription in order to subscribe again at the end each billing period.
In google play console there is no option to create non renewable subscription like iOS as follow as below.
iOS create plan page
Please guide me how to create non renewable subscription in google play console.

A non renewable subscription is actually a normal consumable One-time product.
the only difference between subscription and One-time product, is that the subscription is recurring (renewed)
from Google Play's billing system overview
You can use Google Play's billing system to sell the following types of digital content:
One-time products: A one-time product is content that users can purchase with a single, non-recurring charge to the user's form of payment.
One-time products can be either consumable or non-consumable:
A consumable product is one that a user consumes to receive in-app content, such as in-game currency. When a user consumes the product, your app dispenses the associated content, and the user can then purchase the item again.
A non-consumable product is a product that is purchased only once to provide a permanent benefit. Examples include premium upgrades and level packs.
Subscriptions: A subscription is a product that provides access to content on a recurring basis. Subscriptions renew automatically until they're canceled. Examples of subscriptions include access to online magazines and music streaming services.

This can be helpful to you !
//First, you need to initializes
private void Initialize(){
billingClient = BillingClient.newBuilder(context)
.setListener(new PurchasesUpdatedListener() {
#Override
public void onPurchasesUpdated(#NonNull #NotNull BillingResult billingResult, List<Purchase> list) {
// Google Play calls this to deliver the result of the purchase operation to this listener
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null){
for(Purchase purchase : list){
// since we have only passes a productId at LaunchPurchaseFlow
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
GotPurchase(purchase);
if(isAutoAcknowledge && !isSubscription){
HandleNonConsumable(purchase);
}
}
});
}
}else if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED){
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
PurchaseCancelled();
}
});
}else{
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
PurchaseFailed(billingResult.getResponseCode());
}
});
}
}
})
.enablePendingPurchases()
.build();
}
// To start connection
public void StartConnection(){
billingClient.startConnection(new BillingClientStateListener() {
#Override
public void onBillingServiceDisconnected() {
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
BillingServiceDisconnect();
}
});
}
#Override
public void onBillingSetupFinished(#NonNull #NotNull BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
BillingClientReady();
}
});
}
}
});
}
// To launch purchase flow use this method, productId is your product id and skuType can be subs or inapp . If you need for subs then pass skuType as subs
public void LaunchPurchaseFlow(String productId, String skuType){
String idOfProduct = isTest ? "android.test.purchased" : productId;
isSubscription = skuType.equals(BillingClient.SkuType.SUBS);
if(billingClient.isReady()){
List<String> skuList = new ArrayList<>();
skuList.add(idOfProduct);
SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder()
.setSkusList(skuList)
.setType(skuType)
.build();
billingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() {
#Override
public void onSkuDetailsResponse(#NonNull #NotNull BillingResult billingResult, List<SkuDetails> list) {
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null){
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setSkuDetails(list.get(0))
.build();
billingClient.launchBillingFlow(activity , billingFlowParams);
}else{
FailedToLaunchPurchaseFlow(billingResult.getResponseCode());
}
}
});
}else{
OnError("Billing Client is not ready");
}
}
If you are doing for InApp purchase ie, either consumable or non-conumable, you should handle the purchase like this
// Consumable
public void HandleConsumable(Object purchase){
if(purchase instanceof Purchase){
Purchase purchase1 = (Purchase) purchase;
if(purchase1.getPurchaseState() == Purchase.PurchaseState.PENDING){
PurchaseStatePending();
}else if(purchase1.getPurchaseState() == Purchase.PurchaseState.UNSPECIFIED_STATE){
PurchaseStateUnspecified();
}else{
if(!purchase1.isAcknowledged()){ // TO know if payment is acknowledged, if not it means the payment is not successful/acknowledged yet.
ConsumeParams consumeParams = ConsumeParams.newBuilder()
.setPurchaseToken(purchase1.getPurchaseToken())
.build();
ConsumeResponseListener listener = new ConsumeResponseListener() {
#Override
public void onConsumeResponse(#NonNull #NotNull BillingResult billingResult, #NonNull #NotNull String s) {
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK){
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
PurchaseSuccess();
}
});
}else{
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
PurchaseFailed(billingResult.getResponseCode());
}
});
}
}
};
billingClient.consumeAsync(consumeParams , listener);
}
}
}else{
OnError("purchase is not an instance of Purchase");
}
}
// Non-Consumable or Acknowledged
public void HandleNonConsumable(Object purchase){
if(purchase instanceof Purchase){
Purchase purchase1 = (Purchase) purchase;
if(purchase1.getPurchaseState() == Purchase.PurchaseState.PENDING){
PurchaseStatePending();
}else if(purchase1.getPurchaseState() == Purchase.PurchaseState.UNSPECIFIED_STATE){
PurchaseStateUnspecified();
}else if(purchase1.getPurchaseState() == Purchase.PurchaseState.PURCHASED){
if(!purchase1.isAcknowledged()){
AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase1.getPurchaseToken())
.build();
AcknowledgePurchaseResponseListener listener = new AcknowledgePurchaseResponseListener() {
#Override
public void onAcknowledgePurchaseResponse(#NonNull #NotNull BillingResult billingResult) {
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK){
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
PurchaseSuccess();
}
});
}else{
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
PurchaseFailed(billingResult.getResponseCode());
}
});
}
}
};
billingClient.acknowledgePurchase(acknowledgePurchaseParams , listener);
}
}
}else{
OnError("purchase is not an instance of Purchase");
}
}

Related

login twitter account in android app with twitter kit

I'm making an android app using Java as a language. The idea of ​​this app is to be able to log me in with my twitter account and be able to get the name, email and image of the account which should be shown in a kind of user profile in the app In order to log in, I'm using the package: twitterkit: 3.1.1 but I can't connect with my account, this is what I have so far:
public class loggin extends AppCompatActivity {
//pruebas twitter:
TwitterAuthClient mTwitterAuthClient;
TwitterApiClient twitterApiClient;
StatusesService statusesService;
//variable twitter
TwitterLoginButton login;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Twitter.initialize(this);
login = (TwitterLoginButton) findViewById(R.id.twitter_login_button);
login.setCallback(new Callback<TwitterSession>() {
#Override
public void success(Result<TwitterSession> result) {
TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
TwitterAuthToken authToken = session.getAuthToken();
login(session);
Toast.makeText(loggin.this, "falto poco", Toast.LENGTH_SHORT).show();
}
#Override
public void failure(TwitterException exception) {
Toast.makeText(loggin.this, "casiiiiii", Toast.LENGTH_SHORT).show();
}
});
}
public void login(TwitterSession session){
long userId = session.getUserId();
String userName = session.getUserName();
Intent intent =new Intent(loggin.this,MainActivity.class);
intent.putExtra("username",userName);
startActivity(intent);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
login.onActivityResult(requestCode, resultCode, data);
}

how can i retrieve different child firebase database in single activity

I am trying to retrieve data from Firebase Database and set them to text view. My database has different multiple child data. I want to retrieve all child in a single activity like globally. I have a different card view click in the main activity. when I click on any item it does not show the same child data with related that item. It shows single child data on every item click. How can I get them in a signal Activity on card view click? I am new to Android and I have tried multiple answers here, but failed. Can anyone help me with this?
public class GlobalActivity extends AppCompatActivity
RecyclerView mRecyclerView;
List<User> myUserList;
User mUser;
ProgressDialog progressDialog;
private DatabaseReference db;
private ValueEventListener eventListener;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_global);
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Please wait its loding..");
mRecyclerView = (RecyclerView) findViewById(R.id.farazList);
GridLayoutManager gridLayoutManager = new GridLayoutManager(AhmedFarazActivity.this, 1);
mRecyclerView.setLayoutManager(gridLayoutManager);
myUserList = new ArrayList<>();
final ReAdapter reAdapter = new ReAdapter(GlobalActivity.this, myUserList);
mRecyclerView.setAdapter(reAdapter);
db = FirebaseDatabase.getInstance().getReference().child("Spinner").child("US");
progressDialog.show();
eventListener = db.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
myUserList.clear();
for (DataSnapshot ds : dataSnapshot.getChildren()) {
User userData = ds.getValue(User.class);
myUserList.add(userData);
}
reAdapter.notifyDataSetChanged();
progressDialog.dismiss();
}
#Override
public void onCancelled(DatabaseError databaseError) {
progressDialog.dismiss();
}
});
}
}
Handle to click
This is handler in the adapter when I click on any item it does not show the same child data with related that item. It shows single child data on every item click.
#Override
public void onBindViewHolder(#NonNull MyHolder holder, int position) {
// Hide data
holder.nameText.setText(models.get(position).getName());
holder.img.setImageResource(models.get(position).getImg());
holder.setItemClickListener(new ItemClickListener() {
#Override
public void onItemClick(View view, int pos) {
//Go to UK Item to show UK data
if (models.get(pos).getName().equals("US")){
//Start Display Activity on click
Toast.makeText(c, "US", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(c, GlobalActivity.class);
c.startActivity(intent);
}
//Go to UK Item to show UK data
if (models.get(pos).getName().equals("UK")){
//Start System Info Activity on click
Toast.makeText(c, "UK", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(c, GlobalActivity.class);
c.startActivity(intent);
}
}
});
}
Now i figure out my solution
I add just Intent.putExtra("data","1"); in every handler click
#Override
public void onBindViewHolder(#NonNull MyHolder holder, int position) {
// Hide data
holder.nameText.setText(models.get(position).getName());
holder.img.setImageResource(models.get(position).getImg());
holder.setItemClickListener(new ItemClickListener() {
#Override
public void onItemClick(View view, int pos) {
//Go to UK Item to show UK data
if (models.get(pos).getName().equals("US")){
//Start Display Activity on click
Toast.makeText(c, "US", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(c, GlobalActivity.class);
intent.putExtra("data","1");
c.startActivity(intent);
}
//Go to UK Item to show UK data
if (models.get(pos).getName().equals("UK")){
//Start System Info Activity on click
Toast.makeText(c, "UK", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(c, GlobalActivity.class);
intent.putExtra("data","2");
c.startActivity(intent);
}
}
});
}
In GlobalActivity i create a method for data
initialize data(); inside onCreate
public class GlobalActivity extends AppCompatActivity
RecyclerView mRecyclerView;
List<User> myUserList;
User mUser;
ProgressDialog progressDialog;
private DatabaseReference db;
private ValueEventListener eventListener;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_global);
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Please wait its loding..");
mRecyclerView = (RecyclerView) findViewById(R.id.farazList);
GridLayoutManager gridLayoutManager = new GridLayoutManager(AhmedFarazActivity.this, 1);
mRecyclerView.setLayoutManager(gridLayoutManager);
myUserList = new ArrayList<>();
final ReAdapter reAdapter = new ReAdapter(GlobalActivity.this, myUserList);
mRecyclerView.setAdapter(reAdapter);
data();
progressDialog.show();
eventListener = db.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
myUserList.clear();
for (DataSnapshot ds : dataSnapshot.getChildren()) {
User userData = ds.getValue(User.class);
myUserList.add(userData);
}
reAdapter.notifyDataSetChanged();
progressDialog.dismiss();
}
#Override
public void onCancelled(DatabaseError databaseError) {
progressDialog.dismiss();
}
});
}
method for getting
public void data() {
String data = getIntent().getStringExtra("data");
if (data.equals("1")) {
db = FirebaseDatabase.getInstance().getReference().child("Spinner").child("India");
db.keepSynced(true);
} else if (data.equals("2")) {
db = FirebaseDatabase.getInstance().getReference().child("Spinner").child("Pak");
db.keepSynced(true);
} else if (data.equals("3")) {
db = FirebaseDatabase.getInstance().getReference().child("Spinner").child("UK");
db.keepSynced(true);
}
}

Why isn't an custom implemented VaadinServiceInitListener is listening in vaadin 13.0.2?

I would like to validate user is signed in or not to achieve it i found something called VaadinServiceInitListener in vaadin 13.0.2 This class is used to listen to BeforeEnter event of all UIs in order to check whether a user is signed in or not before allowing entering any page.
I have created an vaadin 13.0.2 project with app-layout-addon by appreciated implemented login functionality and VaadinServiceInitListener to check whether a user is signed in or not.
public class AAACATInitListener implements VaadinServiceInitListener {
private static final long serialVersionUID = 1L;
private static InAppSessionContextImpl appContextImpl;
#Override
public void serviceInit(ServiceInitEvent event) {
System.out.println("in service init event");
event.getSource().addUIInitListener(new UIInitListener() {
private static final long serialVersionUID = 1L;
#Override
public void uiInit(UIInitEvent event) {
event.getUI().addBeforeEnterListener(new BeforeEnterListener() {
private static final long serialVersionUID = 1L;
#Override
public void beforeEnter(BeforeEnterEvent event) {
appContextImpl = (InAppSessionContextImpl)VaadinSession.getCurrent().getAttribute("context");
if (appContextImpl == null) {
WebBrowser webBrowser = UI.getCurrent().getSession().getBrowser();
String address = webBrowser.getAddress();
if(RememberAuthService.isAuthenticated(address) != null && !RememberAuthService.isAuthenticated(address).isEmpty()) {
//System.out.println("Found Remembered User....");
IBLSessionContext iblSessionContext = null;
try {
iblSessionContext = new UserBLManager().doRememberedStaffUserLogin(RememberAuthService.isAuthenticated(address), "");
if(iblSessionContext != null) {
InAppSessionContextImpl localAppContextImpl = new InAppSessionContextImpl();
localAppContextImpl.setBLSessionContext(iblSessionContext);
localAppContextImpl.setModuleGroupList(iblSessionContext.getSessionAccessControl().getPermittedModuleGroups());
appContextImpl = localAppContextImpl;
event.rerouteTo(ApplicationMainView.class);
}else {
Notification.show("Your access has been expired, Please contact your administrator", 5000, Position.BOTTOM_CENTER);
}
} catch (AuthenticationFailedException e) {
Notification.show("Authentication Failed, Please Reset Cookies And Try Again", 5000, Position.BOTTOM_CENTER);
} catch (Exception e){
e.printStackTrace();
Notification.show("Unexpected Error Occurred, Please Reset Cookies And Try Again", 5000, Position.BOTTOM_CENTER);
}
}else {
System.out.println("Session context is null, creating new context");
appContextImpl = new InAppSessionContextImpl();
VaadinSession.getCurrent().setAttribute("context", appContextImpl);
event.rerouteTo(LoginView.class);
}
} else {
System.out.println("Session context is not null");
InAppSessionContextImpl localAppContextImpl = new InAppSessionContextImpl();
localAppContextImpl.setBLSessionContext(appContextImpl.getBLSessionContext());
localAppContextImpl.setModuleGroupList(appContextImpl.getModuleGroupList());
appContextImpl = localAppContextImpl;
event.rerouteTo(ApplicationMainView.class);
}
}
});
}
});
}
public static void setBLSessionContext(IBLSessionContext iblSessionContext) {
appContextImpl.setBLSessionContext(iblSessionContext);
}
public static void setModuleGroupList(List<ModuleGroupVO> moduleGroupList) {
appContextImpl.setModuleGroupList(moduleGroupList);
}
private class InAppSessionContextImpl implements InAppSessionContext {
private static final long serialVersionUID = 1L;
private List<ModuleGroupVO> moduleGroupList;
private IBLSessionContext iblSessionContext;
private Map<String, Object> attributeMap;
public InAppSessionContextImpl() {
this.attributeMap = new HashMap<String, Object>();
}
#Override
public List<ModuleGroupVO> getModuleGroupList() {
return moduleGroupList;
}
public void setModuleGroupList(List<ModuleGroupVO> moduleGroupList) {
this.moduleGroupList = moduleGroupList;
}
#Override
public IBLSessionContext getBLSessionContext() {
return iblSessionContext;
}
public void setBLSessionContext(IBLSessionContext iblSessionContext) {
this.iblSessionContext = iblSessionContext;
}
#Override
public IBLSession getBLSession() {
if(iblSessionContext != null)
return iblSessionContext.getBLSession();
return null;
}
#Override
public boolean isPermittedAction(String actionAlias) {
if (getBLSessionContext() != null) {
if (getBLSessionContext().getSessionAccessControl() != null) {
return getBLSessionContext().getSessionAccessControl().isPermittedAction(actionAlias);
}
}
return false;
}
#Override
public void setAttribute(String key, Object attribute) {
attributeMap.put(key, attribute);
}
#Override
public Object getAttribute(String key) {
return attributeMap.get(key);
}
}
}
Expected results redirect to login page if user not signed in or else to main application page but AAACATInitListener is not listening.
If you are using Spring, simply add a #Component annotation to the class and it should work. If youre not using Spring, follow #codinghaus' answer.
To make Vaadin recognize the VaadinServiceInitListener you have to create a file called com.vaadin.flow.server.VaadinServiceInitListener and put it under src/main/resources/META-INF/services. Its content should be the full path to the class that implements the VaadinServiceInitListener interface. Did you do that?
You can also find a description on that in the tutorial.
The correct pattern to use beforeEnter(..) is not do it via VaadinServiceInitListener , instead you should implement BeforeEnterObserver interface in the view where you need use it and override beforeEnter(..) method with your implementation.
public class MainView extends VerticalLayout implements RouterLayout, BeforeEnterObserver {
...
#Override
public void beforeEnter(BeforeEnterEvent event) {
...
}
}

Twitter4j for getting tweets

I have write this simple code for getting tweets from twitter
public static void main(String[] args) throws TwitterException {
// TODO code application logic here
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("**********")
.setOAuthConsumerSecret("**************")
.setOAuthAccessToken("***************")
.setOAuthAccessTokenSecret("**************");
TwitterFactory tf= new TwitterFactory(cb.build());
twitter4j.Twitter tw= tf.getInstance();
List<Status> statuses = tw.getHomeTimeline();
for(Status status1 : statuses){
System.out.println(status1.getUser().getName()+ " : "+ status1.getText());
}
But I want to get about 4000 tweets in urdu language. I don't know how to do. please help me
With that code you will only get Tweets from the Timeline of the register user, from Twitter4j:
ResponseList getHomeTimeline() Returns the 20 most recent
statuses, including retweets, posted by the authenticating user and
that user's friends. This is the equivalent of /timeline/home on the
Web."
If you want to get at least 4000 tweets in urdu you could do several things, for example you could get the sample stream from Twitter:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("**********")
.setOAuthConsumerSecret("**************")
.setOAuthAccessToken("***************")
.setOAuthAccessTokenSecret("**************");
TwitterStream twitterStream = new TwitterStreamFactory(cb.build())
.getInstance();
StatusListener listener = new StatusListener() {
#Override
public void onStatus(Status status) {
System.out.println("#"+status.getUser().getScreenName()+": "+status.getText());
// HERE YOU STORE YOUR TWEETS
}
#Override
public void onException(Exception ex) {
ex.printStackTrace();
}
#Override
public void onDeletionNotice(StatusDeletionNotice arg0) {
// TODO Auto-generated method stub
}
#Override
public void onScrubGeo(long arg0, long arg1) {
}
#Override
public void onStallWarning(StallWarning arg0) {
// TODO Auto-generated method stub
System.out.println(arg0);
}
#Override
public void onTrackLimitationNotice(int arg0) {
// TODO Auto-generated method stub
System.out.println(arg0);
}
};
twitterStream.addListener(listener);
twitterStream.sample("ur");
Until you get the 4000 tweets that you want.
You can use twitter search instead of just getting specific user's tweets. What I have done for getting tweets in Turkish language is just using twitter's advanced search feature. In my situation adding lang:tr after specified search phrase returned tweets in Turkish language to me. You can use lang:ur instead of lang:tr for getting tweets in Urdu Language.
Here is my code:
public class TwitterDataGetter implements Runnable {
private Thread twitterDataGetterThread;
final static Logger logger = Logger.getLogger(TwitterDataGetter.class);
public TwitterDataGetter() {
try {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("your consumer key");
cb.setOAuthConsumerSecret("your consumer secret");
cb.setOAuthAccessToken("your access token");
cb.setOAuthAccessTokenSecret("your access token secret");
cb.setIncludeEntitiesEnabled(true);
this.twitter = new TwitterFactory(cb.build()).getInstance();
logger.info("Twitter API Configuration Successful");
} catch (Exception e) {
logger.error("Twitter API Configuration Error", e);
}
}
public void getTweet(String keyword){
List<Status> statuses = null;
Query query;
QueryResult result;
try {
query = new Query(keyword + " lang:tr");
query.setCount(100);
do {
final long startTime = System.nanoTime();
result = twitter.search(query);
statuses = result.getTweets();
for (Status status : statuses) {
System.out.println(status.getText());
}
final long duration = System.nanoTime() - startTime;
if((5500 - duration/1000000) > 0){
Thread.sleep((5500 - duration/1000000));
}
} while ((query = result.nextQuery()) != null);
} catch (TwitterException e) {
logger.error("TwitterException", e);
} catch (InterruptedException e) {
logger.error("InterruptedException", e);
throw new RuntimeException(e);
}
}
#Override
public void run() {
while(true){
this.getTweet("");
}
}
public void start(){
if(twitterDataGetterThread == null){
twitterDataGetterThread = new Thread(this, "Twitter Thread");
}
twitterDataGetterThread.start();
logger.info("Twitter Thread started");
}
}
Calling getTweet(String keyword) method with empty string returns latest tweets in your language without filtering them with any keyword.
Hope it helps.
PS: you can also check search results for your language from this link https://twitter.com/search?f=tweets&vertical=default&q=lang%3Aur

How to use twitter4j along with storm

I use the twitter4j query interface to filter tweets http://twitter4j.org/javadoc/twitter4j/Query.html. But the twitter spout in https://github.com/nathanmarz/storm-starter/blob/master/src/jvm/storm/starter/spout/TwitterSampleSpout.java:43 uses queue.offer(status). I don't have a reference to Status, how do I integrate these API(s) to process live tweets.
This is what we have been using successfully to filter tweets:
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
queue = new LinkedBlockingQueue<Status>(1000);
_collector = collector;
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
queue.offer(status);
}
public void onDeletionNotice(StatusDeletionNotice sdn) {
}
public void onTrackLimitationNotice(int i) {
}
public void onScrubGeo(long l, long l1) {
}
public void onException(Exception e) {
}
};
TwitterStreamFactory fact = new TwitterStreamFactory(new ConfigurationBuilder().setUser(_username).setPassword(_pwd).build());
_twitterStream = fact.getInstance();
_twitterStream.addListener(listener);
_twitterStream.filter(new FilterQuery().track(TERMS_TO_TRACK).setIncludeEntities(true));
}

Resources