Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] how to solve the network latency when opening the app

hi sir / mdm

this is peiyuan, i worte a MQTT programming using andriod, during my testing

i found out that whenever i turn on my 3G network the starting up of the app took a very long time

but however when i turn off the 3G and wifi network, after clicking the button it turn on automatically 

when i integrate this coding with my another programing that i wrote i face this issue.

May i known how to solve this problem

Currently i am using eclipse java client and andriod serice

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.roti.mqtt" >
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!-- Mqtt Service -->
<service android:name="org.eclipse.paho.android.service.MqttService"> </service>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
public void buttonOnclick (View v)
{
try {

client = new MqttClient(TCPaddress, clientid);

boolean result = client.isConnected();



if (!client.isConnected()==result)
{
System.out.println("fail to connect");
Toast toast = Toast.makeText(null,"fail",Toast.LENGTH_LONG);
toast.show();



}
else
{
client.connect();
System.out.println("connect sucessful");
Toast toast = Toast.makeText(null,"fail",Toast.LENGTH_LONG);
toast.show();
}


}

catch (Exception e)
{
e.printStackTrace();
}

}
}

Kindly please advise me how to solve this issue thank you

from
peiyuan













Back to the top