Skip to content

Commit 2157ed5

Browse files
committed
add onNewIntent handler and NewIntentListener interface
1 parent 6745539 commit 2157ed5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pythonforandroid/bootstraps/qt5/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,40 @@ protected void onPostExecute(String result) {
160160
}
161161
}
162162

163+
//----------------------------------------------------------------------------
164+
// Listener interface for onNewIntent
165+
//
166+
167+
public interface NewIntentListener {
168+
void onNewIntent(Intent intent);
169+
}
170+
171+
private List<NewIntentListener> newIntentListeners = null;
172+
173+
public void registerNewIntentListener(NewIntentListener listener) {
174+
if ( this.newIntentListeners == null )
175+
this.newIntentListeners = Collections.synchronizedList(new ArrayList<NewIntentListener>());
176+
this.newIntentListeners.add(listener);
177+
}
178+
179+
public void unregisterNewIntentListener(NewIntentListener listener) {
180+
if ( this.newIntentListeners == null )
181+
return;
182+
this.newIntentListeners.remove(listener);
183+
}
184+
185+
@Override
186+
protected void onNewIntent(Intent intent) {
187+
if ( this.newIntentListeners == null )
188+
return;
189+
this.onResume();
190+
synchronized ( this.newIntentListeners ) {
191+
Iterator<NewIntentListener> iterator = this.newIntentListeners.iterator();
192+
while ( iterator.hasNext() ) {
193+
(iterator.next()).onNewIntent(intent);
194+
}
195+
}
196+
}
197+
163198
}
164199

0 commit comments

Comments
 (0)