How can i 'run' this app in android studio? [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0
















This question already has an answer here:




  • How to solve error “Default Activity Not Found” occurred when starting my application from Service?

    3 answers




I learn tizen app, i try to use sample app - hello accesory.



this is document. but it's so much simple and i can't understand how to run...



https://developer.samsung.com/galaxy-watch/develop/samples/companion/hello-native



this project has 2 part, tizen app and android service.
but i use android service first.



i import(open) project in android studio and connect my phone. but i push 'run' or 'debug' button, this error occur.



Error running 'app'
Default Activity not found


i see a blog, he say 'use build - generate signed apk'. it work. i install to my phone through apk file.
but i can't know it really work. because i install tizen app and try connect, tizen-android connect isn't work....



i think android service is problem or tizen app is problem, but i can't any test on android.



i want how to know service is running now and how to debug in android studio.
lower is androidManifest.xml and source code.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samsung.android.sdk.accessory.example.helloaccessory.provider"
android:versionCode="4"
android:versionName="2.0.2" >

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />

<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" >

<service android:name="com.samsung.android.sdk.accessory.example.helloaccessory.provider.ProviderService" />

<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.REGISTER_AGENT" />
</intent-filter>
</receiver>
<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.SERVICE_CONNECTION_REQUESTED" />
</intent-filter>
</receiver>

<meta-data
android:name="AccessoryServicesLocation"
android:value="/res/xml/accessoryservices.xml" />
<meta-data
android:name="GearAppType"
android:value="tpk" />
</application>

</manifest>


source code.



package com.samsung.android.sdk.accessory.example.helloaccessory.provider;


import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;
import android.util.Log;

import com.samsung.android.sdk.SsdkUnsupportedException;
import com.samsung.android.sdk.accessory.*;

public class ProviderService extends SAAgent {
private static final String TAG = "HelloAccessory(P)";
private static final Class<ServiceConnection> SASOCKET_CLASS = ServiceConnection.class;
private final IBinder mBinder = new LocalBinder();
private ServiceConnection mConnectionHandler = null;
Handler mHandler = new Handler();

public ProviderService() {
super(TAG, SASOCKET_CLASS);
}

@Override
public void onCreate() {
super.onCreate();
SA mAccessory = new SA();
try {
mAccessory.initialize(this);
} catch (SsdkUnsupportedException e) {
// try to handle SsdkUnsupportedException
if (processUnsupportedException(e) == true) {
return;
}
} catch (Exception e1) {
e1.printStackTrace();
/*
* Your application can not use Samsung Accessory SDK. Your application should work smoothly
* without using this SDK, or you may want to notify user and close your application gracefully
* (release resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
}
}

@Override
public IBinder onBind(Intent intent) {
return mBinder;
}

@Override
protected void onFindPeerAgentsResponse(SAPeerAgent peerAgents, int result) {
Log.d(TAG, "onFindPeerAgentResponse : result =" + result);
}

@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent) {
if (peerAgent != null) {
Toast.makeText(getBaseContext(), R.string.ConnectionAcceptedMsg, Toast.LENGTH_SHORT).show();
acceptServiceConnectionRequest(peerAgent);
}
}

@Override
protected void onServiceConnectionResponse(SAPeerAgent peerAgent, SASocket socket, int result) {
if (result == SAAgent.CONNECTION_SUCCESS) {
if (socket != null) {
mConnectionHandler = (ServiceConnection) socket;
}
} else if (result == SAAgent.CONNECTION_ALREADY_EXIST) {
Log.e(TAG, "onServiceConnectionResponse, CONNECTION_ALREADY_EXIST");
}
}

@Override
protected void onAuthenticationResponse(SAPeerAgent peerAgent, SAAuthenticationToken authToken, int error) {
/*
* The authenticatePeerAgent(peerAgent) API may not be working properly depending on the firmware
* version of accessory device. Please refer to another sample application for Security.
*/
}

@Override
protected void onError(SAPeerAgent peerAgent, String errorMessage, int errorCode) {
super.onError(peerAgent, errorMessage, errorCode);
}

private boolean processUnsupportedException(SsdkUnsupportedException e) {
e.printStackTrace();
int errType = e.getType();
if (errType == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED
|| errType == SsdkUnsupportedException.DEVICE_NOT_SUPPORTED) {
/*
* Your application can not use Samsung Accessory SDK. You application should work smoothly
* without using this SDK, or you may want to notify user and close your app gracefully (release
* resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
} else if (errType == SsdkUnsupportedException.LIBRARY_NOT_INSTALLED) {
Log.e(TAG, "You need to install Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_REQUIRED) {
Log.e(TAG, "You need to update Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) {
Log.e(TAG, "We recommend that you update your Samsung Accessory SDK before using this application.");
return false;
}
return true;
}

public class LocalBinder extends Binder {
public ProviderService getService() {
return ProviderService.this;
}
}

public class ServiceConnection extends SASocket {
public ServiceConnection() {
super(ServiceConnection.class.getName());
}

@Override
public void onError(int channelId, String errorMessage, int errorCode) {
}

@Override
public void onReceive(int channelId, byte data) {
if (mConnectionHandler == null) {
return;
}
Calendar calendar = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd aa hh:mm:ss.SSS");
String timeStr = " " + dateFormat.format(calendar.getTime());
String strToUpdateUI = new String(data);
final String message = strToUpdateUI.concat(timeStr);
new Thread(new Runnable() {
public void run() {
try {
mConnectionHandler.send(getServiceChannelId(0), message.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}

@Override
protected void onServiceConnectionLost(int reason) {
mConnectionHandler = null;
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getBaseContext(), R.string.ConnectionTerminateddMsg, Toast.LENGTH_SHORT).show();
}
});
}
}
}









share|improve this question













marked as duplicate by Henry, Community Nov 27 '18 at 2:07


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Error shows there's no Default Activity

    – Ashish
    Nov 22 '18 at 9:09


















0
















This question already has an answer here:




  • How to solve error “Default Activity Not Found” occurred when starting my application from Service?

    3 answers




I learn tizen app, i try to use sample app - hello accesory.



this is document. but it's so much simple and i can't understand how to run...



https://developer.samsung.com/galaxy-watch/develop/samples/companion/hello-native



this project has 2 part, tizen app and android service.
but i use android service first.



i import(open) project in android studio and connect my phone. but i push 'run' or 'debug' button, this error occur.



Error running 'app'
Default Activity not found


i see a blog, he say 'use build - generate signed apk'. it work. i install to my phone through apk file.
but i can't know it really work. because i install tizen app and try connect, tizen-android connect isn't work....



i think android service is problem or tizen app is problem, but i can't any test on android.



i want how to know service is running now and how to debug in android studio.
lower is androidManifest.xml and source code.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samsung.android.sdk.accessory.example.helloaccessory.provider"
android:versionCode="4"
android:versionName="2.0.2" >

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />

<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" >

<service android:name="com.samsung.android.sdk.accessory.example.helloaccessory.provider.ProviderService" />

<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.REGISTER_AGENT" />
</intent-filter>
</receiver>
<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.SERVICE_CONNECTION_REQUESTED" />
</intent-filter>
</receiver>

<meta-data
android:name="AccessoryServicesLocation"
android:value="/res/xml/accessoryservices.xml" />
<meta-data
android:name="GearAppType"
android:value="tpk" />
</application>

</manifest>


source code.



package com.samsung.android.sdk.accessory.example.helloaccessory.provider;


import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;
import android.util.Log;

import com.samsung.android.sdk.SsdkUnsupportedException;
import com.samsung.android.sdk.accessory.*;

public class ProviderService extends SAAgent {
private static final String TAG = "HelloAccessory(P)";
private static final Class<ServiceConnection> SASOCKET_CLASS = ServiceConnection.class;
private final IBinder mBinder = new LocalBinder();
private ServiceConnection mConnectionHandler = null;
Handler mHandler = new Handler();

public ProviderService() {
super(TAG, SASOCKET_CLASS);
}

@Override
public void onCreate() {
super.onCreate();
SA mAccessory = new SA();
try {
mAccessory.initialize(this);
} catch (SsdkUnsupportedException e) {
// try to handle SsdkUnsupportedException
if (processUnsupportedException(e) == true) {
return;
}
} catch (Exception e1) {
e1.printStackTrace();
/*
* Your application can not use Samsung Accessory SDK. Your application should work smoothly
* without using this SDK, or you may want to notify user and close your application gracefully
* (release resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
}
}

@Override
public IBinder onBind(Intent intent) {
return mBinder;
}

@Override
protected void onFindPeerAgentsResponse(SAPeerAgent peerAgents, int result) {
Log.d(TAG, "onFindPeerAgentResponse : result =" + result);
}

@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent) {
if (peerAgent != null) {
Toast.makeText(getBaseContext(), R.string.ConnectionAcceptedMsg, Toast.LENGTH_SHORT).show();
acceptServiceConnectionRequest(peerAgent);
}
}

@Override
protected void onServiceConnectionResponse(SAPeerAgent peerAgent, SASocket socket, int result) {
if (result == SAAgent.CONNECTION_SUCCESS) {
if (socket != null) {
mConnectionHandler = (ServiceConnection) socket;
}
} else if (result == SAAgent.CONNECTION_ALREADY_EXIST) {
Log.e(TAG, "onServiceConnectionResponse, CONNECTION_ALREADY_EXIST");
}
}

@Override
protected void onAuthenticationResponse(SAPeerAgent peerAgent, SAAuthenticationToken authToken, int error) {
/*
* The authenticatePeerAgent(peerAgent) API may not be working properly depending on the firmware
* version of accessory device. Please refer to another sample application for Security.
*/
}

@Override
protected void onError(SAPeerAgent peerAgent, String errorMessage, int errorCode) {
super.onError(peerAgent, errorMessage, errorCode);
}

private boolean processUnsupportedException(SsdkUnsupportedException e) {
e.printStackTrace();
int errType = e.getType();
if (errType == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED
|| errType == SsdkUnsupportedException.DEVICE_NOT_SUPPORTED) {
/*
* Your application can not use Samsung Accessory SDK. You application should work smoothly
* without using this SDK, or you may want to notify user and close your app gracefully (release
* resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
} else if (errType == SsdkUnsupportedException.LIBRARY_NOT_INSTALLED) {
Log.e(TAG, "You need to install Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_REQUIRED) {
Log.e(TAG, "You need to update Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) {
Log.e(TAG, "We recommend that you update your Samsung Accessory SDK before using this application.");
return false;
}
return true;
}

public class LocalBinder extends Binder {
public ProviderService getService() {
return ProviderService.this;
}
}

public class ServiceConnection extends SASocket {
public ServiceConnection() {
super(ServiceConnection.class.getName());
}

@Override
public void onError(int channelId, String errorMessage, int errorCode) {
}

@Override
public void onReceive(int channelId, byte data) {
if (mConnectionHandler == null) {
return;
}
Calendar calendar = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd aa hh:mm:ss.SSS");
String timeStr = " " + dateFormat.format(calendar.getTime());
String strToUpdateUI = new String(data);
final String message = strToUpdateUI.concat(timeStr);
new Thread(new Runnable() {
public void run() {
try {
mConnectionHandler.send(getServiceChannelId(0), message.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}

@Override
protected void onServiceConnectionLost(int reason) {
mConnectionHandler = null;
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getBaseContext(), R.string.ConnectionTerminateddMsg, Toast.LENGTH_SHORT).show();
}
});
}
}
}









share|improve this question













marked as duplicate by Henry, Community Nov 27 '18 at 2:07


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Error shows there's no Default Activity

    – Ashish
    Nov 22 '18 at 9:09














0












0








0









This question already has an answer here:




  • How to solve error “Default Activity Not Found” occurred when starting my application from Service?

    3 answers




I learn tizen app, i try to use sample app - hello accesory.



this is document. but it's so much simple and i can't understand how to run...



https://developer.samsung.com/galaxy-watch/develop/samples/companion/hello-native



this project has 2 part, tizen app and android service.
but i use android service first.



i import(open) project in android studio and connect my phone. but i push 'run' or 'debug' button, this error occur.



Error running 'app'
Default Activity not found


i see a blog, he say 'use build - generate signed apk'. it work. i install to my phone through apk file.
but i can't know it really work. because i install tizen app and try connect, tizen-android connect isn't work....



i think android service is problem or tizen app is problem, but i can't any test on android.



i want how to know service is running now and how to debug in android studio.
lower is androidManifest.xml and source code.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samsung.android.sdk.accessory.example.helloaccessory.provider"
android:versionCode="4"
android:versionName="2.0.2" >

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />

<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" >

<service android:name="com.samsung.android.sdk.accessory.example.helloaccessory.provider.ProviderService" />

<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.REGISTER_AGENT" />
</intent-filter>
</receiver>
<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.SERVICE_CONNECTION_REQUESTED" />
</intent-filter>
</receiver>

<meta-data
android:name="AccessoryServicesLocation"
android:value="/res/xml/accessoryservices.xml" />
<meta-data
android:name="GearAppType"
android:value="tpk" />
</application>

</manifest>


source code.



package com.samsung.android.sdk.accessory.example.helloaccessory.provider;


import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;
import android.util.Log;

import com.samsung.android.sdk.SsdkUnsupportedException;
import com.samsung.android.sdk.accessory.*;

public class ProviderService extends SAAgent {
private static final String TAG = "HelloAccessory(P)";
private static final Class<ServiceConnection> SASOCKET_CLASS = ServiceConnection.class;
private final IBinder mBinder = new LocalBinder();
private ServiceConnection mConnectionHandler = null;
Handler mHandler = new Handler();

public ProviderService() {
super(TAG, SASOCKET_CLASS);
}

@Override
public void onCreate() {
super.onCreate();
SA mAccessory = new SA();
try {
mAccessory.initialize(this);
} catch (SsdkUnsupportedException e) {
// try to handle SsdkUnsupportedException
if (processUnsupportedException(e) == true) {
return;
}
} catch (Exception e1) {
e1.printStackTrace();
/*
* Your application can not use Samsung Accessory SDK. Your application should work smoothly
* without using this SDK, or you may want to notify user and close your application gracefully
* (release resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
}
}

@Override
public IBinder onBind(Intent intent) {
return mBinder;
}

@Override
protected void onFindPeerAgentsResponse(SAPeerAgent peerAgents, int result) {
Log.d(TAG, "onFindPeerAgentResponse : result =" + result);
}

@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent) {
if (peerAgent != null) {
Toast.makeText(getBaseContext(), R.string.ConnectionAcceptedMsg, Toast.LENGTH_SHORT).show();
acceptServiceConnectionRequest(peerAgent);
}
}

@Override
protected void onServiceConnectionResponse(SAPeerAgent peerAgent, SASocket socket, int result) {
if (result == SAAgent.CONNECTION_SUCCESS) {
if (socket != null) {
mConnectionHandler = (ServiceConnection) socket;
}
} else if (result == SAAgent.CONNECTION_ALREADY_EXIST) {
Log.e(TAG, "onServiceConnectionResponse, CONNECTION_ALREADY_EXIST");
}
}

@Override
protected void onAuthenticationResponse(SAPeerAgent peerAgent, SAAuthenticationToken authToken, int error) {
/*
* The authenticatePeerAgent(peerAgent) API may not be working properly depending on the firmware
* version of accessory device. Please refer to another sample application for Security.
*/
}

@Override
protected void onError(SAPeerAgent peerAgent, String errorMessage, int errorCode) {
super.onError(peerAgent, errorMessage, errorCode);
}

private boolean processUnsupportedException(SsdkUnsupportedException e) {
e.printStackTrace();
int errType = e.getType();
if (errType == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED
|| errType == SsdkUnsupportedException.DEVICE_NOT_SUPPORTED) {
/*
* Your application can not use Samsung Accessory SDK. You application should work smoothly
* without using this SDK, or you may want to notify user and close your app gracefully (release
* resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
} else if (errType == SsdkUnsupportedException.LIBRARY_NOT_INSTALLED) {
Log.e(TAG, "You need to install Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_REQUIRED) {
Log.e(TAG, "You need to update Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) {
Log.e(TAG, "We recommend that you update your Samsung Accessory SDK before using this application.");
return false;
}
return true;
}

public class LocalBinder extends Binder {
public ProviderService getService() {
return ProviderService.this;
}
}

public class ServiceConnection extends SASocket {
public ServiceConnection() {
super(ServiceConnection.class.getName());
}

@Override
public void onError(int channelId, String errorMessage, int errorCode) {
}

@Override
public void onReceive(int channelId, byte data) {
if (mConnectionHandler == null) {
return;
}
Calendar calendar = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd aa hh:mm:ss.SSS");
String timeStr = " " + dateFormat.format(calendar.getTime());
String strToUpdateUI = new String(data);
final String message = strToUpdateUI.concat(timeStr);
new Thread(new Runnable() {
public void run() {
try {
mConnectionHandler.send(getServiceChannelId(0), message.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}

@Override
protected void onServiceConnectionLost(int reason) {
mConnectionHandler = null;
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getBaseContext(), R.string.ConnectionTerminateddMsg, Toast.LENGTH_SHORT).show();
}
});
}
}
}









share|improve this question















This question already has an answer here:




  • How to solve error “Default Activity Not Found” occurred when starting my application from Service?

    3 answers




I learn tizen app, i try to use sample app - hello accesory.



this is document. but it's so much simple and i can't understand how to run...



https://developer.samsung.com/galaxy-watch/develop/samples/companion/hello-native



this project has 2 part, tizen app and android service.
but i use android service first.



i import(open) project in android studio and connect my phone. but i push 'run' or 'debug' button, this error occur.



Error running 'app'
Default Activity not found


i see a blog, he say 'use build - generate signed apk'. it work. i install to my phone through apk file.
but i can't know it really work. because i install tizen app and try connect, tizen-android connect isn't work....



i think android service is problem or tizen app is problem, but i can't any test on android.



i want how to know service is running now and how to debug in android studio.
lower is androidManifest.xml and source code.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.samsung.android.sdk.accessory.example.helloaccessory.provider"
android:versionCode="4"
android:versionName="2.0.2" >

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="com.samsung.WATCH_APP_TYPE.Companion" />
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION" />

<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" >

<service android:name="com.samsung.android.sdk.accessory.example.helloaccessory.provider.ProviderService" />

<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.REGISTER_AGENT" />
</intent-filter>
</receiver>
<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver" >
<intent-filter>
<action android:name="com.samsung.accessory.action.SERVICE_CONNECTION_REQUESTED" />
</intent-filter>
</receiver>

<meta-data
android:name="AccessoryServicesLocation"
android:value="/res/xml/accessoryservices.xml" />
<meta-data
android:name="GearAppType"
android:value="tpk" />
</application>

</manifest>


source code.



package com.samsung.android.sdk.accessory.example.helloaccessory.provider;


import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;
import android.util.Log;

import com.samsung.android.sdk.SsdkUnsupportedException;
import com.samsung.android.sdk.accessory.*;

public class ProviderService extends SAAgent {
private static final String TAG = "HelloAccessory(P)";
private static final Class<ServiceConnection> SASOCKET_CLASS = ServiceConnection.class;
private final IBinder mBinder = new LocalBinder();
private ServiceConnection mConnectionHandler = null;
Handler mHandler = new Handler();

public ProviderService() {
super(TAG, SASOCKET_CLASS);
}

@Override
public void onCreate() {
super.onCreate();
SA mAccessory = new SA();
try {
mAccessory.initialize(this);
} catch (SsdkUnsupportedException e) {
// try to handle SsdkUnsupportedException
if (processUnsupportedException(e) == true) {
return;
}
} catch (Exception e1) {
e1.printStackTrace();
/*
* Your application can not use Samsung Accessory SDK. Your application should work smoothly
* without using this SDK, or you may want to notify user and close your application gracefully
* (release resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
}
}

@Override
public IBinder onBind(Intent intent) {
return mBinder;
}

@Override
protected void onFindPeerAgentsResponse(SAPeerAgent peerAgents, int result) {
Log.d(TAG, "onFindPeerAgentResponse : result =" + result);
}

@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent) {
if (peerAgent != null) {
Toast.makeText(getBaseContext(), R.string.ConnectionAcceptedMsg, Toast.LENGTH_SHORT).show();
acceptServiceConnectionRequest(peerAgent);
}
}

@Override
protected void onServiceConnectionResponse(SAPeerAgent peerAgent, SASocket socket, int result) {
if (result == SAAgent.CONNECTION_SUCCESS) {
if (socket != null) {
mConnectionHandler = (ServiceConnection) socket;
}
} else if (result == SAAgent.CONNECTION_ALREADY_EXIST) {
Log.e(TAG, "onServiceConnectionResponse, CONNECTION_ALREADY_EXIST");
}
}

@Override
protected void onAuthenticationResponse(SAPeerAgent peerAgent, SAAuthenticationToken authToken, int error) {
/*
* The authenticatePeerAgent(peerAgent) API may not be working properly depending on the firmware
* version of accessory device. Please refer to another sample application for Security.
*/
}

@Override
protected void onError(SAPeerAgent peerAgent, String errorMessage, int errorCode) {
super.onError(peerAgent, errorMessage, errorCode);
}

private boolean processUnsupportedException(SsdkUnsupportedException e) {
e.printStackTrace();
int errType = e.getType();
if (errType == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED
|| errType == SsdkUnsupportedException.DEVICE_NOT_SUPPORTED) {
/*
* Your application can not use Samsung Accessory SDK. You application should work smoothly
* without using this SDK, or you may want to notify user and close your app gracefully (release
* resources, stop Service threads, close UI thread, etc.)
*/
stopSelf();
} else if (errType == SsdkUnsupportedException.LIBRARY_NOT_INSTALLED) {
Log.e(TAG, "You need to install Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_REQUIRED) {
Log.e(TAG, "You need to update Samsung Accessory SDK to use this application.");
} else if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) {
Log.e(TAG, "We recommend that you update your Samsung Accessory SDK before using this application.");
return false;
}
return true;
}

public class LocalBinder extends Binder {
public ProviderService getService() {
return ProviderService.this;
}
}

public class ServiceConnection extends SASocket {
public ServiceConnection() {
super(ServiceConnection.class.getName());
}

@Override
public void onError(int channelId, String errorMessage, int errorCode) {
}

@Override
public void onReceive(int channelId, byte data) {
if (mConnectionHandler == null) {
return;
}
Calendar calendar = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd aa hh:mm:ss.SSS");
String timeStr = " " + dateFormat.format(calendar.getTime());
String strToUpdateUI = new String(data);
final String message = strToUpdateUI.concat(timeStr);
new Thread(new Runnable() {
public void run() {
try {
mConnectionHandler.send(getServiceChannelId(0), message.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}

@Override
protected void onServiceConnectionLost(int reason) {
mConnectionHandler = null;
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(getBaseContext(), R.string.ConnectionTerminateddMsg, Toast.LENGTH_SHORT).show();
}
});
}
}
}




This question already has an answer here:




  • How to solve error “Default Activity Not Found” occurred when starting my application from Service?

    3 answers








android android-studio android-service tizen






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 8:33









RedwingsRedwings

6818




6818




marked as duplicate by Henry, Community Nov 27 '18 at 2:07


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Henry, Community Nov 27 '18 at 2:07


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Error shows there's no Default Activity

    – Ashish
    Nov 22 '18 at 9:09



















  • Error shows there's no Default Activity

    – Ashish
    Nov 22 '18 at 9:09

















Error shows there's no Default Activity

– Ashish
Nov 22 '18 at 9:09





Error shows there's no Default Activity

– Ashish
Nov 22 '18 at 9:09












1 Answer
1






active

oldest

votes


















1














Your app project don't have activity declared,
You need to have activity with this attribute



        <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>


Example:



    <activity
android:name=".MainActivity"
android:label="@string/app_name"
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


You need to declare launch activity for avoid the




Default Activity not found







share|improve this answer
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Your app project don't have activity declared,
    You need to have activity with this attribute



            <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>


    Example:



        <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>


    You need to declare launch activity for avoid the




    Default Activity not found







    share|improve this answer






























      1














      Your app project don't have activity declared,
      You need to have activity with this attribute



              <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>


      Example:



          <activity
      android:name=".MainActivity"
      android:label="@string/app_name"
      <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      </activity>


      You need to declare launch activity for avoid the




      Default Activity not found







      share|improve this answer




























        1












        1








        1







        Your app project don't have activity declared,
        You need to have activity with this attribute



                <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>


        Example:



            <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity>


        You need to declare launch activity for avoid the




        Default Activity not found







        share|improve this answer















        Your app project don't have activity declared,
        You need to have activity with this attribute



                <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>


        Example:



            <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity>


        You need to declare launch activity for avoid the




        Default Activity not found








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 '18 at 9:08









        Ashish

        628321




        628321










        answered Nov 22 '18 at 9:03









        BenjaminBenjamin

        13710




        13710

















            Popular posts from this blog

            How to send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?