小编Spa*_*lug的帖子

如何获取 EC2 实例的 CloudWatch 指标数据

我想为我的 EC2 实例获取 Cloudmetrics 数据,以便我可以使用这些数据绘制图形并将其显示在我的 android 设备上。我怎么做?是否有相同的示例程序或教程?

提前致谢。

这就是我正在做的:

private static void findCloudWatchData()  {

    AmazonCloudWatchClient cloudWatch = new AmazonCloudWatchClient(new BasicAWSCredentials(AccessKey, SecretKey));
    cloudWatch.setEndpoint("monitoring.us-east-1.amazonaws.com");
    long offsetInMilliseconds = 1000 * 60 * 60 * 24;
    Dimension instanceDimension = new Dimension();
    instanceDimension.setName("instanceid");
    instanceDimension.setValue(instanceid);

    GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
            .withStartTime(new Date(new Date().getTime() - offsetInMilliseconds))
            .withNamespace("AWS/EC2")
            .withPeriod(60 * 60)
            .withMetricName("CPUUtilization")
            .withStatistics("Average")
            .withDimensions(Arrays.asList(instanceDimension))
            .withEndTime(new Date());

    GetMetricStatisticsResult getMetricStatisticsResult = cloudWatch.getMetricStatistics(request);
    }
Run Code Online (Sandbox Code Playgroud)

java android amazon-ec2 amazon-web-services amazon-cloudwatch

5
推荐指数
1
解决办法
8626
查看次数

位置经理ProxmityAlert总是说进入

我想在他靠近特定位置时提醒用户.为此,我在我的应用程序中包含了ProxmityAlert和相应的服务.但无论我给出什么样的坐标,它总是向我显示"感谢您访问我的区域!!进入"我这样做是错误的吗?

这就是我这样做的方式:

public class ProxTest extends Activity {
LocationManager lm;
double lat = 30.085514, long1 = 77.082603;
float radius = 50;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    lm = (LocationManager) getSystemService(LOCATION_SERVICE);
    Intent i = new Intent();
    i.setAction("com.example.test.proximityalert");

    PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(),
            -1, i, 0);
    lm.addProximityAlert(lat, long1, radius, -1, pi);
    sendBroadcast(i);
    System.out.println("Prox alert added ");
}
Run Code Online (Sandbox Code Playgroud)

}

这是接收者:

public class ProximityReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
    // TODO Auto-generated method stub
    String k …
Run Code Online (Sandbox Code Playgroud)

android locationmanager geofencing

5
推荐指数
1
解决办法
147
查看次数

如何在android中绘制带有Time的x轴和另一个的图形?

我想绘制时间值的关系图,其中时间(小时)在x轴上,值应在y轴上.有没有图书馆可以做到这一点?我尝试使用achartengine http://wptrafficanalyzer.in/blog/android-drawing-time-chart-with-timeseries-in-achartengine/,但没有多大帮助.

java android graph android-graphview

3
推荐指数
1
解决办法
5712
查看次数

如何在android中设置预定通知

即使应用程序没有运行,我希望我的应用程序在10秒后发出通知.我已经使用了AlarmManager但无法在所需的时间收到通知.我当时能够举杯祝酒而不是通知.任何帮助将深表感谢.

这是我的AlarmManager类:

public class AlarmManagerActivity extends Activity {

private AlarmManagerBroadcastReceiver alarm;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm_manager);
    alarm = new AlarmManagerBroadcastReceiver();
    onetimeTimer();


}

@Override
protected void onStart() {
    super.onStart();
}


public void notifyN(){

    Intent intent = new Intent(this, NotificationReceiverActivity.class);
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

    // Build notification
    // Actions are just fake
    Notification noti = new Notification.Builder(this)
            .setContentTitle("This is a sample notification")
            .setContentText("Subject")
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentIntent(pIntent)
            .addAction(R.drawable.ic_action_search, "Call", pIntent)
            .addAction(R.drawable.ic_action_search, "More", pIntent)
            .addAction(R.drawable.ic_action_search, "And more", …
Run Code Online (Sandbox Code Playgroud)

notifications android alarm alarmmanager

2
推荐指数
1
解决办法
8391
查看次数

ClassCastException:java.util.ArrayList不是Comparable

我的Hash映射中有两个数组,我想根据timeStampArray中的时间对averageValueArray中存储的值进行排序.我正在使用,TreeMap但我得到的ClassCastException是说ArrayList无法比较.

这就是我在做的事情:

Map<List<Date>,List<Double>> sortMap = new HashMap<List<Date>,List<Double>>();
            sortMap.put(timeStampArray, averageValueArray);

            for (Map.Entry entry : sortMap.entrySet()) {
                System.out.println("Key = " + entry.getKey());
                System.out.println(" Value = " +entry.getValue());

            }
            System.out.println("Unsort Map......");
            printMap(sortMap);

            System.out.println("Sorted Map......");
            TreeMap<List<Date>,List<Double>> treeMap = new TreeMap<List<Date>,List<Double>>(sortMap);
            for (Map.Entry entry : treeMap.entrySet()) {
                System.out.println("Key = " + entry.getKey());
                System.out.println(" Value = " +entry.getValue());

            }


            printMap(treeMap);
Run Code Online (Sandbox Code Playgroud)

printMap是:

public static void printMap(Map<List<Date>,List<Double>> map) {
for (Map.Entry entry : map.entrySet()) {
    System.out.println("Key : " + entry.getKey() + " Value : …
Run Code Online (Sandbox Code Playgroud)

java mapping hashmap treemap

0
推荐指数
1
解决办法
440
查看次数