Question: I am trying to display just the last post for each user and having messed around for a while, I cannot work it out.

I have relationships of users has many posts and posts belong to users. 
When I use the below code it correctly puts each users email address but it puts the value for each post as the last overall value (not the last value for that specific user).

```
<% @users.each do |u| %>
  <%= @posts.last.total %>
  <%= u.email %>
<% end %>

```

(Total is a calculation performed in posts model and saved in the db.)

Answer: 
I'll try to give you a simple example how to "call a public method" in activity.

First you need to add in `manifest` to your activity

```
  <activity ..
      android:launchMode= "singleInstance" />

```

Then inside `Helper.class` initialize some custom actions

```
public static final String SOME_ACTION1 = "some_action1"
public static final String SOME_ACTION2 = "some_action2"

private void someAction(){
    Intent intent = new Intent(a, USBCommunicationManager.class);
    intent.setAction(SOME_ACTION1)
    a.startActivity(intent);//this calls onNewIntent method in launched activity
}

```

In `USBCommunicationManager` override `onNewIntent`

```
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    String action = intent.getAction()

   //now you can check this action and use desired method
}

```

But i recomended to read about `BroadcastReceiver` because with this solution you can accidentally launch activity. But using broadcast you just unregister it on activity destroy and don't worries about activity restarting.
Call another class method by creating object of that class

```html
USBCommunicationManager ucm= new USBCommunicationManager();
ucm.methodName();
```