Rhyston Da Silva in MATLAB Answers
최근 활동: 2021년 9월 2일

I am attempting to take a user input value on an android application and then upload that value to ThingSpeak for further use. I am trying to use Android Studio and Kotlin, but I keep getting the same error. Any guidance will be much appreciated as I would just like to get the application to run. I have created a Button to execute and Two Texts - Number (Signed) for input. Below is the code that I have attempted: import android.os.Bundle import android.view.View import android.widget.Button import androidx.appcompat.app.AppCompatActivity import com.squareup.okhttp.Request import com.squareup.okhttp.OkHttpClient class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val waterAmount = findViewById<View>(R.id.WaterAmount) val temperatureAmount = findViewById<View>(R.id.TemperatureAmount) val dispenseButton = findViewById<Button>(R.id.DispenseButton) dispenseButton.setOnClickListener { val okHttpClient = OkHttpClient() val builder: Request.Builder = Request.Builder() val request: Request = builder.url("https://api.thingspeak.com/update?api_key=APIKEY&field1=" + waterAmount).build() } } } The error that I keep receiving is: Duplicate class org.objectweb.asm.AnnotationVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.AnnotationWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Attribute found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ByteVector found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ClassReader found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ClassVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.ClassWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Edge found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.FieldVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.FieldWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Frame found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Handler found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Item found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Label found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.MethodVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.MethodWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Opcodes found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.Type found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.signature.SignatureReader found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.signature.SignatureVisitor found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Duplicate class org.objectweb.asm.signature.SignatureWriter found in modules jetified-asm-3.1 (asm:asm:3.1) and jetified-asm-4.0 (org.ow2.asm:asm:4.0) Go to the documentation to learn how to Fix dependency resolution errors.
YU CHIANG CHENG in MATLAB Answers
최근 활동: 2018년 10월 7일

this is my thingspeak chart <</matlabcentral/answers/uploaded_files/135202/thingspeak%E5%9C%96.PNG>> I want to show Field 1 2 3 chart and this is my android studio app chart <</matlabcentral/answers/uploaded_files/135203/app%E5%9C%96.png>> the time interval can't show like thingspeak's chart and this is my code package com.macroyau.thingspeakandroid.demo; import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; import com.macroyau.thingspeakandroid.ThingSpeakChannel; import com.macroyau.thingspeakandroid.ThingSpeakLineChart; import com.macroyau.thingspeakandroid.model.ChannelFeed; import java.time.DayOfWeek; import java.time.Month; import java.util.Calendar; import java.util.Date; import lecho.lib.hellocharts.model.LineChartData; import lecho.lib.hellocharts.model.Viewport; import lecho.lib.hellocharts.view.LineChartView; public class DemoActivity extends AppCompatActivity { private ThingSpeakChannel tsChannel; private ThingSpeakLineChart tsChart,tsChart2,tsChart3; private LineChartView chartView,chartView2,chartView3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Connect to ThinkSpeak Channel 9 tsChannel = new ThingSpeakChannel(566541); // Set listener for Channel feed update events tsChannel.setChannelFeedUpdateListener(new ThingSpeakChannel.ChannelFeedUpdateListener() { @Override public void onChannelFeedUpdated(long channelId, String channelName, ChannelFeed channelFeed) { // Show Channel ID and name on the Action Bar getSupportActionBar().setTitle(channelName); getSupportActionBar().setSubtitle("Channel " + channelId); // Notify last update time of the Channel feed through a Toast message Date lastUpdate = channelFeed.getChannel().getUpdatedAt(); Toast.makeText(DemoActivity.this, lastUpdate.toString(), Toast.LENGTH_LONG).show(); } }); // Fetch the specific Channel feed tsChannel.loadChannelFeed(); // Create a Calendar object dated 5 minutes ago Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH,-2); //calendar.roll(Calendar.DATE, 1); // 只增加月的欄位值為10個月 // Configure LineChartView chartView = findViewById(R.id.chart); chartView2 = findViewById(R.id.chart2); chartView3 = findViewById(R.id.chart3); chartView.setZoomEnabled(true); chartView.setValueSelectionEnabled(true); chartView2.setZoomEnabled(true); chartView2.setValueSelectionEnabled(true); chartView3.setZoomEnabled(true); chartView3.setValueSelectionEnabled(true); // Create a line chart from Field1 of ThinkSpeak Channel 9 tsChart = new ThingSpeakLineChart(566541, 1); tsChart2 = new ThingSpeakLineChart(566541,2); tsChart3 = new ThingSpeakLineChart(566541,3); // Get 200 entries at maximum tsChart.setNumberOfEntries(50); // Set value axis labels on 10-unit interval tsChart.setValueAxisLabelInterval(8); // Set date axis labels on 5-minute interval tsChart.setDateAxisLabelInterval(-2); // Show the line as a cubic spline tsChart.useSpline(false); // Set the line color tsChart.setLineColor(Color.parseColor("#D32F2F")); // Set the axis color tsChart.setAxisColor(Color.parseColor("#455a64")); // Set the starting date (5 minutes ago) for the default viewport of the chart tsChart.setChartStartDate(calendar.getTime()); // Set listener for chart data update tsChart.setListener(new ThingSpeakLineChart.ChartDataUpdateListener() { @Override public void onChartDataUpdated(long channelId, int fieldId, String title, LineChartData lineChartData, Viewport maxViewport, Viewport initialViewport) { // Set chart data to the LineChartView chartView.setLineChartData(lineChartData); // Set scrolling bounds of the chart chartView.setMaximumViewport(maxViewport); // Set the initial chart bounds chartView.setCurrentViewport(initialViewport); } }); // Load chart data asynchronously tsChart.loadChartData(); tsChart2.setNumberOfEntries(30); // Set value axis labels on 10-unit interval tsChart2.setValueAxisLabelInterval(10); // Set date axis labels on 5-minute interval tsChart2.setDateAxisLabelInterval(10); // Show the line as a cubic spline tsChart2.useSpline(false); // Set the line color tsChart2.setLineColor(Color.parseColor("#D32F2F")); // Set the axis color tsChart2.setAxisColor(Color.parseColor("#455a64")); // Set the starting date (5 minutes ago) for the default viewport of the chart tsChart2.setChartStartDate(calendar.getTime()); // Set listener for chart data update tsChart2.setListener(new ThingSpeakLineChart.ChartDataUpdateListener() { @Override public void onChartDataUpdated(long channelId, int fieldId, String title, LineChartData lineChartData, Viewport maxViewport, Viewport initialViewport) { // Set chart data to the LineChartView chartView2.setLineChartData(lineChartData); // Set scrolling bounds of the chart chartView2.setMaximumViewport(maxViewport); // Set the initial chart bounds chartView2.setCurrentViewport(initialViewport); } }); // Load chart data asynchronously tsChart2.loadChartData(); tsChart3.setNumberOfEntries(30); // Set value axis labels on 10-unit interval tsChart3.setValueAxisLabelInterval(2); // Set date axis labels on 5-minute interval tsChart3.setDateAxisLabelInterval(10); // Show the line as a cubic spline tsChart3.useSpline(false); // Set the line color tsChart3.setLineColor(Color.parseColor("#D32F2F")); // Set the axis color tsChart3.setAxisColor(Color.parseColor("#455a64")); // Set the starting date (5 minutes ago) for the default viewport of the chart tsChart3.setChartStartDate(calendar.getTime()); // Set listener for chart data update tsChart3.setListener(new ThingSpeakLineChart.ChartDataUpdateListener() { @Override public void onChartDataUpdated(long channelId, int fieldId, String title, LineChartData lineChartData, Viewport maxViewport, Viewport initialViewport) { // Set chart data to the LineChartView chartView3.setLineChartData(lineChartData); // Set scrolling bounds of the chart chartView3.setMaximumViewport(maxViewport); // Set the initial chart bounds chartView3.setCurrentViewport(initialViewport); } }); // Load chart data asynchronously tsChart3.loadChartData(); } } Thank you for everyone

ThingSpeak 정보

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.